[Sqlalchemy-commits] [1092] sqlalchemy/trunk/test: moved name to 'defaults', going to put more defau
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-03-04 19:29:48
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[1092] sqlalchemy/trunk/test: moved name to 'defaults', going to put more default stuff in</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1092</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-03-04 13:29:05 -0600 (Sat, 04 Mar 2006)</dd> </dl> <h3>Log Message</h3> <pre>moved name to 'defaults', going to put more default stuff in</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunktestalltestspy">sqlalchemy/trunk/test/alltests.py</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#sqlalchemytrunktestdefaultspy">sqlalchemy/trunk/test/defaults.py</a></li> </ul> <h3>Removed Paths</h3> <ul> <li><a href="#sqlalchemytrunktestsequencepy">sqlalchemy/trunk/test/sequence.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunktestalltestspy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/alltests.py (1091 => 1092)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/alltests.py 2006-03-04 19:26:23 UTC (rev 1091) +++ sqlalchemy/trunk/test/alltests.py 2006-03-04 19:29:05 UTC (rev 1092) </span><span class="lines">@@ -27,8 +27,8 @@ </span><span class="cx"> # assorted round-trip tests </span><span class="cx"> 'query', </span><span class="cx"> </span><del>- # sequences (postgres/oracle) - 'sequence', </del><ins>+ # defaults, sequences (postgres/oracle) + 'defaults', </ins><span class="cx"> </span><span class="cx"> # ORM selecting </span><span class="cx"> 'mapper', </span></span></pre></div> <a id="sqlalchemytrunktestdefaultspyfromrev1091sqlalchemytrunktestsequencepy"></a> <div class="copfile"><h4>Copied: sqlalchemy/trunk/test/defaults.py (from rev 1091, sqlalchemy/trunk/test/sequence.py) ( => )</h4> <pre class="diff"><span> <span class="info">Deleted: sqlalchemy/trunk/test/sequence.py =================================================================== </span><del>--- sqlalchemy/trunk/test/sequence.py 2006-03-04 19:26:23 UTC (rev 1091) </del><ins>+++ sqlalchemy/trunk/test/sequence.py 2006-03-04 19:29:05 UTC (rev 1092) </ins><span class="lines">@@ -1,111 +0,0 @@ </span><del>-from testbase import PersistTest -import sqlalchemy.util as util -import unittest, sys, os -import sqlalchemy.schema as schema -import testbase -from sqlalchemy import * -import sqlalchemy - -db = testbase.db - -class DefaultTest(PersistTest): - - def testdefaults(self): - x = {'x':50} - def mydefault(): - x['x'] += 1 - return x['x'] - - use_function_defaults = db.engine.name == 'postgres' or db.engine.name == 'oracle' - is_oracle = db.engine.name == 'oracle' - - # select "count(1)" from the DB which returns different results - # on different DBs - if is_oracle: - f = select([func.count(1) + 5], engine=db, from_obj=['DUAL']).scalar() - ts = select([func.sysdate()], engine=db, from_obj=['DUAL']).scalar() - def1 = func.sysdate() - def2 = text("sysdate") - deftype = Date - elif use_function_defaults: - f = select([func.count(1) + 5], engine=db).scalar() - def1 = func.current_date() - def2 = text("current_date") - deftype = Date - ts = select([func.current_date()], engine=db).scalar() - else: - f = select([func.count(1) + 5], engine=db).scalar() - def1 = def2 = "3" - ts = 3 - deftype = Integer - - t = Table('default_test1', db, - # python function - Column('col1', Integer, primary_key=True, default=mydefault), - - # python literal - Column('col2', String(20), default="imthedefault"), - - # preexecute expression - Column('col3', Integer, default=func.count(1) + 5), - - # SQL-side default from sql expression - Column('col4', deftype, PassiveDefault(def1)), - - # SQL-side default from literal expression - Column('col5', deftype, PassiveDefault(def2)) - ) - t.create() - try: - t.insert().execute() - self.assert_(t.engine.lastrow_has_defaults()) - t.insert().execute() - t.insert().execute() - - l = t.select().execute() - self.assert_(l.fetchall() == [(51, 'imthedefault', f, ts, ts), (52, 'imthedefault', f, ts, ts), (53, 'imthedefault', f, ts, ts)]) - finally: - t.drop() - -class SequenceTest(PersistTest): - - def setUpAll(self): - if testbase.db.engine.name != 'postgres' and testbase.db.engine.name != 'oracle': - return - global cartitems - cartitems = Table("cartitems", db, - Column("cart_id", Integer, Sequence('cart_id_seq'), primary_key=True), - Column("description", String(40)), - Column("createdate", DateTime()) - ) - - cartitems.create() - - def testsequence(self): - cartitems.insert().execute(description='hi') - cartitems.insert().execute(description='there') - cartitems.insert().execute(description='lala') - - cartitems.select().execute().fetchall() - - - def teststandalone(self): - s = Sequence("my_sequence", engine=db) - s.create() - try: - x =s.execute() - self.assert_(x == 1) - finally: - s.drop() - - def teststandalone2(self): - x = cartitems.c.cart_id.sequence.execute() - self.assert_(1 <= x <= 4) - - def tearDownAll(self): - if testbase.db.engine.name != 'postgres' and testbase.db.engine.name != 'oracle': - return - cartitems.drop() - -if __name__ == "__main__": - unittest.main() </del></span></pre> </div> </div> </body> </html> |