]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Added testbase.Table and testbase.Column, interceptors that can set up
authorJason Kirtland <jek@discorporate.us>
Fri, 15 Jun 2007 22:35:53 +0000 (22:35 +0000)
committerJason Kirtland <jek@discorporate.us>
Fri, 15 Jun 2007 22:35:53 +0000 (22:35 +0000)
  test-run- and dialect-specific options on those objects
  All tests re-pointed to go through the interceptors
- Removed mysql_engine= from table declarations, replaced with a general
  flag indicating storage requirements
- Added ability to choose a global MySQL storage engine for all tests
  --mysql-engine=<whatever>
  If none is specified, tests use the old db-default/InnoDB behavior
- Added ability to append arbitrary table creation params
  --table-option=KEY=VALUE
  For MySQL 3, use this to set mysql_type instead of --mysql-engine
- Removed a couple dead test modules

62 files changed:
test/dialect/mysql.py
test/engine/autoconnect_engine.py [deleted file]
test/engine/execute.py
test/engine/metadata.py
test/engine/reflection.py
test/engine/transaction.py
test/ext/assignmapper.py
test/ext/associationproxy.py
test/ext/orderinglist.py
test/ext/selectresults.py
test/ext/wsgi_test.py [deleted file]
test/orm/association.py
test/orm/cascade.py
test/orm/compile.py
test/orm/cycles.py
test/orm/eagertest1.py
test/orm/eagertest2.py
test/orm/eagertest3.py
test/orm/entity.py
test/orm/fixtures.py
test/orm/generative.py
test/orm/inheritance/abc_inheritance.py
test/orm/inheritance/basic.py
test/orm/inheritance/concrete.py
test/orm/inheritance/magazine.py
test/orm/inheritance/manytomany.py
test/orm/inheritance/poly_linked_list.py
test/orm/inheritance/polymorph.py
test/orm/inheritance/polymorph2.py
test/orm/inheritance/productspec.py
test/orm/inheritance/single.py
test/orm/lazytest1.py
test/orm/manytomany.py
test/orm/memusage.py
test/orm/merge.py
test/orm/onetoone.py
test/orm/query.py
test/orm/relationships.py
test/orm/sessioncontext.py
test/orm/unitofwork.py
test/perf/cascade_speed.py
test/perf/masseagerload.py
test/perf/massload.py
test/perf/massload2.py
test/perf/masssave.py
test/perf/poolload.py
test/perf/threaded_compile.py
test/perf/wsgi.py
test/sql/case_statement.py
test/sql/constraints.py
test/sql/defaults.py
test/sql/labels.py
test/sql/query.py
test/sql/quote.py
test/sql/rowcount.py
test/sql/select.py
test/sql/selectable.py
test/sql/testtypes.py
test/sql/unicode.py
test/tables.py
test/testbase.py
test/zblog/tables.py

index bcef161a3475aea5dc7a103c8ed60e57145c4db4..784993cc45692570693080aaa04e99fab300e740 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest, AssertMixin
 import testbase
 from sqlalchemy import *
 from sqlalchemy.databases import mysql
+from testbase import Table, Column
 import sys, StringIO
 
 db = testbase.db
diff --git a/test/engine/autoconnect_engine.py b/test/engine/autoconnect_engine.py
deleted file mode 100644 (file)
index 69c2c33..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-from testbase import PersistTest
-import testbase
-from sqlalchemy import *
-from sqlalchemy.ext.proxy import AutoConnectEngine
-
-import os
-
-#
-# Define an engine, table and mapper at the module level, to show that the
-# table and mapper can be used with different real engines in multiple threads
-#
-
-
-module_engine = AutoConnectEngine( testbase.db_uri )
-users = Table('users', module_engine, 
-              Column('user_id', Integer, primary_key=True),
-              Column('user_name', String(16)),
-              Column('password', String(20))
-              )
-
-class User(object):
-    pass
-
-
-class AutoConnectEngineTest1(PersistTest):
-
-    def setUp(self):
-        clear_mappers()
-        objectstore.clear()
-        
-    def test_engine_connect(self):
-        users.create()
-        assign_mapper(User, users)
-        try:
-            trans = objectstore.begin()
-
-            user = User()
-            user.user_name='fred'
-            user.password='*'
-            trans.commit()
-
-            # select
-            sqluser = User.select_by(user_name='fred')[0]
-            assert sqluser.user_name == 'fred'
-
-            # modify
-            sqluser.user_name = 'fred jones'
-
-            # commit - saves everything that changed
-            objectstore.commit()
-        
-            allusers = [ user.user_name for user in User.select() ]
-            assert allusers == [ 'fred jones' ]
-        finally:
-            users.drop()
-
-
-        
-        
-if __name__ == "__main__":
-    testbase.main()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
index 33c25201824faecd20fb1a4292b31c2520bcf220..c8e23d3debfc0cec0a243138992aabef2f30ca22 100644 (file)
@@ -4,7 +4,7 @@ import unittest, sys, datetime
 import tables
 db = testbase.db
 from sqlalchemy import *
-
+from testbase import Table, Column
 
 class ExecuteTest(testbase.PersistTest):
     def setUpAll(self):
@@ -13,7 +13,6 @@ class ExecuteTest(testbase.PersistTest):
         users = Table('users', metadata,
             Column('user_id', INT, primary_key = True),
             Column('user_name', VARCHAR(20)),
-            mysql_engine='InnoDB'
         )
         metadata.create_all()
     
index 1165170e8bca6780e7d344cfb0258c2d6b002594..c3c6441ef180cdb233f73ac510269823c725acd2 100644 (file)
@@ -1,5 +1,6 @@
 import testbase
 from sqlalchemy import *
+from testbase import Table, Column
 
 class MetaDataTest(testbase.PersistTest):
     def test_metadata_connect(self):
@@ -14,4 +15,4 @@ class MetaDataTest(testbase.PersistTest):
             metadata.drop_all()
     
 if __name__ == '__main__':
-    testbase.main()
\ No newline at end of file
+    testbase.main()
index 41cd236748a034583b084da53429c56a01833e51..d845e43c1fb354e7a0734fa6cb8265696c36f14b 100644 (file)
@@ -6,7 +6,7 @@ import sqlalchemy.ansisql as ansisql
 from sqlalchemy import *
 from sqlalchemy.exceptions import NoSuchTableError
 import sqlalchemy.databases.mysql as mysql
-
+from testbase import Table, Column
 import unittest, re, StringIO
 
 class ReflectionTest(PersistTest):
@@ -15,6 +15,10 @@ class ReflectionTest(PersistTest):
         
         use_string_defaults = use_function_defaults or testbase.db.engine.__module__.endswith('sqlite')
 
+        if (testbase.db.engine.name == 'mysql' and
+            testbase.db.dialect.get_version_info(testbase.db) < (4, 1, 1)):
+            return
+
         if use_function_defaults:
             defval = func.current_date()
             deftype = Date
@@ -54,14 +58,14 @@ class ReflectionTest(PersistTest):
             Column('test_passivedefault4', deftype3, PassiveDefault(defval3)),
             Column('test9', Binary(100)),
             Column('test_numeric', Numeric(None, None)),
-            mysql_engine='InnoDB'
+            test_needs_fk=True,
         )
-
+        
         addresses = Table('engine_email_addresses', meta,
             Column('address_id', Integer, primary_key = True),
             Column('remote_user_id', Integer, ForeignKey(users.c.user_id)),
             Column('email_address', String(20)),
-            mysql_engine='InnoDB'
+            test_needs_fk=True,
         )
         meta.drop_all()
 
@@ -320,6 +324,10 @@ class ReflectionTest(PersistTest):
 
     def test_composite_fk(self):
         """test reflection of composite foreign keys"""
+
+        if (testbase.db.engine.name == 'mysql' and
+            testbase.db.dialect.get_version_info(testbase.db) < (4, 1, 1)):
+            return
         meta = BoundMetaData(testbase.db)
         table = Table(
             'multi', meta, 
@@ -328,7 +336,7 @@ class ReflectionTest(PersistTest):
             Column('multi_hoho', Integer, primary_key=True),
             Column('name', String(50), nullable=False),
             Column('val', String(100)),
-            mysql_engine='InnoDB'
+            test_needs_fk=True,
         )
         table2 = Table('multi2', meta, 
             Column('id', Integer, primary_key=True),
@@ -337,7 +345,7 @@ class ReflectionTest(PersistTest):
             Column('lala', Integer),
             Column('data', String(50)),
             ForeignKeyConstraint(['foo', 'bar', 'lala'], ['multi.multi_id', 'multi.multi_rev', 'multi.multi_hoho']),
-            mysql_engine='InnoDB'
+            test_needs_fk=True,
         )
         assert table.c.multi_hoho
         meta.create_all()
index 86093218ba495ba3af7b746cb6f4129f30c24ffa..96fe7acf4da1b4ff3752472f3325c01293c48198 100644 (file)
@@ -5,7 +5,7 @@ import tables
 db = testbase.db
 from sqlalchemy import *
 from sqlalchemy.orm import *
-
+from testbase import Table, Column
 
 class TransactionTest(testbase.PersistTest):
     def setUpAll(self):
@@ -14,7 +14,7 @@ class TransactionTest(testbase.PersistTest):
         users = Table('query_users', metadata,
             Column('user_id', INT, primary_key = True),
             Column('user_name', VARCHAR(20)),
-            mysql_engine='InnoDB'
+            test_needs_acid=True,
         )
         users.create(testbase.db)
     
@@ -132,6 +132,7 @@ class AutoRollbackTest(testbase.PersistTest):
         users = Table('deadlock_users', metadata,
             Column('user_id', INT, primary_key = True),
             Column('user_name', VARCHAR(20)),
+            test_needs_acid=True,
         )
         users.create(conn1)
         conn1.execute("select * from deadlock_users")
@@ -150,7 +151,7 @@ class TLTransactionTest(testbase.PersistTest):
         users = Table('query_users', metadata,
             Column('user_id', INT, primary_key = True),
             Column('user_name', VARCHAR(20)),
-            mysql_engine='InnoDB'
+            test_needs_acid=True,
         )
         users.create(tlengine)
     def tearDown(self):
@@ -356,7 +357,7 @@ class ForUpdateTest(testbase.PersistTest):
         counters = Table('forupdate_counters', metadata,
             Column('counter_id', INT, primary_key = True),
             Column('counter_value', INT),
-            mysql_engine='InnoDB'
+            test_needs_acid=True,
         )
         counters.create(testbase.db)
     def tearDown(self):
index 479e9f399e7a8278cf8043029f3469ee2ba903ed..c5a2d31916ca205baee4cae081a32f6a484044bd 100644 (file)
@@ -6,6 +6,7 @@ from sqlalchemy.orm import create_session, clear_mappers, relation, class_mapper
 
 from sqlalchemy.ext.assignmapper import assign_mapper
 from sqlalchemy.ext.sessioncontext import SessionContext
+from testbase import Table, Column
 
 class OverrideAttributesTest(PersistTest):
     def setUpAll(self):
@@ -46,4 +47,4 @@ class OverrideAttributesTest(PersistTest):
         assert SomeObject.get_by(id=s.id).options[0].id == sso.id
         
 if __name__ == '__main__':
-    testbase.main()
\ No newline at end of file
+    testbase.main()
index 7a5731d5141fb8b01f45da2a7337b99276bbf14a..98229f397a114a2bf68937656b013adaf147986f 100644 (file)
@@ -5,6 +5,7 @@ import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy.ext.associationproxy import *
+from testbase import Table, Column
 
 db = testbase.db
 
index c2811d5ce06e7b2426239ce5d966a8b1c71de467..dc75d066d777ae8b2d2a4eb86ff3c04f877a6208 100644 (file)
@@ -5,6 +5,7 @@ import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy.ext.orderinglist import *
+from testbase import Table, Column
 
 db = testbase.db
 metadata = None
index eeaff7d549b8ec8b401379f670fd7e6d286c9ad9..8f77b323a6973cc392ada361e602379fc36e9532 100644 (file)
@@ -4,6 +4,7 @@ import tables
 
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 from sqlalchemy.ext.selectresults import SelectResultsExt, SelectResults
 
diff --git a/test/ext/wsgi_test.py b/test/ext/wsgi_test.py
deleted file mode 100644 (file)
index 1330f88..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-"""Interactive wsgi test
-
-Small WSGI application that uses a table and mapper defined at the module
-level, with per-application uris enabled by the ProxyEngine.
-
-Requires the wsgiutils package from:
-
-http://www.owlfish.com/software/wsgiutils/
-
-Run the script with python wsgi_test.py, then visit http://localhost:8080/a
-and http://localhost:8080/b with a browser. You should see two distinct lists
-of colors.
-"""
-
-from sqlalchemy import *
-from sqlalchemy.ext.proxy import ProxyEngine
-from wsgiutils import wsgiServer
-
-engine = ProxyEngine()
-
-colors = Table('colors', engine,
-               Column('id', Integer, primary_key=True),
-               Column('name', String(32)),
-               Column('hex', String(6)))
-
-class Color(object):
-    pass
-
-assign_mapper(Color, colors)
-
-data = { 'a': (('fff','white'), ('aaa','gray'), ('000','black'),
-               ('f00', 'red'), ('0f0', 'green')),
-         'b': (('00f','blue'), ('ff0', 'yellow'), ('0ff','purple')) }
-
-db_uri = { 'a': 'sqlite://filename=wsgi_db_a.db',
-           'b': 'sqlite://filename=wsgi_db_b.db' }
-
-def app(dataset):
-    print '... connecting to database %s: %s' % (dataset, db_uri[dataset])
-    engine.connect(db_uri[dataset], echo=True, echo_pool=True)
-    colors.create()
-
-    print '... populating data into %s' % db_uri[dataset]
-    for hex, name in data[dataset]:
-        c = Color()
-        c.hex = hex
-        c.name = name
-    objectstore.commit()
-    objectstore.clear()
-    
-    def call(environ, start_response):
-        engine.connect(db_uri[dataset], echo=True, echo_pool=True)
-
-        # NOTE: must clear objectstore on each request, or you'll see
-        # objects from another thread here
-        objectstore.clear()
-        objectstore.begin()
-        
-        c = Color.select()
-
-        start_response('200 OK', [('content-type','text/html')])
-        yield '<html><head><title>Test dataset %s</title></head>' % dataset
-        yield '<body>'
-        yield '<p>uri: %s</p>' % db_uri[dataset]
-        yield '<p>engine: <xmp>%s</xmp></p>' % engine.engine
-        yield '<p>Colors!</p>'
-        for color in c:
-            yield '<div style="background: #%s">%s</div>' % (color.hex,
-                                                             color.name)
-        yield '</body></html>'
-    return call
-
-def cleanup():
-    for uri in db_uri.values():
-        print "Cleaning db %s" % uri
-        engine.connect(uri)
-        colors.drop()
-
-def run_server(apps, host='localhost', port=8080):
-    print "Serving test app at http://%s:%s/" % (host, port)
-    print "Visit http://%(host)s:%(port)s/a and " \
-        "http://%(host)s:%(port)s/b to test apps" % {'host': host,
-                                                     'port': port}
-    
-    server = wsgiServer.WSGIServer((host, port), apps, serveFiles=False)
-    try:
-        server.serve_forever()
-    except:
-        cleanup()
-        raise
-    
-if __name__ == '__main__':
-    run_server({'/a':app('a'), '/b':app('b')})
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
index c751ac8a1701f1957586d4f0ed46e930e4b7fceb..61e9bce5f4b15b6be91cd03197c92eacf9f7ee09 100644 (file)
@@ -2,7 +2,7 @@ import testbase
 
 from sqlalchemy import *
 from sqlalchemy.orm import *
-
+from testbase import Table, Column
 
 class AssociationTest(testbase.PersistTest):
     def setUpAll(self):
index 80b846c68235dd8bbdcf114eacf7bbd5cd441622..27e8e7c8fe5bdd2d0aa0310e01b6c4c54e0d5e36 100644 (file)
@@ -4,6 +4,7 @@ import unittest, sys, datetime
 from sqlalchemy.ext.sessioncontext import SessionContext
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 class O2MCascadeTest(testbase.AssertMixin):
     def tearDown(self):
index 604c75d4882b9a2209281247b0f22f0857e40ae5..85aa7c927ea2ba92e90ca21dc11e5460bac88627 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 
 class CompileTest(testbase.AssertMixin):
index dc086b635b845b9f1a6f4015fda84b4b32948821..e9e5f4b9021559403ba9b1d31b5c45effa1e96fc 100644 (file)
@@ -4,6 +4,7 @@ from sqlalchemy import *
 from sqlalchemy.orm import *
 import StringIO
 import testbase
+from testbase import Table, Column
 
 from tables import *
 import tables
index da94c782ab0581934fee93b63d1ab787f1ded062..dd3ad92e57314a1c0590b5b2a726fdde8cfb382e 100644 (file)
@@ -3,6 +3,7 @@ import testbase
 import unittest, sys, os
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 import datetime
 
 class EagerTest(AssertMixin):
index e7bc4c2cb086f97423de3a4f944b59d71eb5e120..0b51ab9dbf6636c749865631703f6bb7fbd50b3d 100644 (file)
@@ -3,8 +3,9 @@ import testbase
 import unittest, sys, os
 from sqlalchemy import *
 from sqlalchemy.orm import *
-import datetime
 from sqlalchemy.ext.sessioncontext import SessionContext
+from testbase import Table, Column
+import datetime
 
 class EagerTest(AssertMixin):
     def setUpAll(self):
index 6453d7ddf751cff845f5d94a863d8647f6141e85..bfcd166434810787a5e4871e98530b47d5c1b056 100644 (file)
@@ -3,6 +3,7 @@ import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy.ext.selectresults import SelectResults
+from testbase import Table, Column
 import random
 
 class EagerTest(AssertMixin):
index 4fc15fef16f1838c3de0704aa518dd09164a0d15..a5346597b4c6d420e31ec424763caccb6201de8a 100644 (file)
@@ -1,9 +1,10 @@
 from testbase import PersistTest, AssertMixin
 import unittest
+import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
-import testbase
 from sqlalchemy.ext.sessioncontext import SessionContext
+from testbase import Table, Column
 
 from tables import *
 import tables
index b79fdb5ba5a03b143fcf57f3360be7464d02f7ae..57991735e53cb6fe849479fa29f2956bc8056fe7 100644 (file)
@@ -1,4 +1,5 @@
 from sqlalchemy import *
+from testbase import Table, Column
 
 class Base(object):
     def __init__(self, **kwargs):
index d4639281651f653c72f05d23a7ff93a4fa90b738..ad07b5b21a1eb90f94aa3e4041aab24637c987de 100644 (file)
@@ -5,6 +5,7 @@ import tables
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy import exceptions
+from testbase import Table, Column
 
 class Foo(object):
     pass
index d85ac39c71ece2887ce879b96886b489beeb5438..7677311739f114b64948e30dd6c671eb78c47135 100644 (file)
@@ -1,5 +1,6 @@
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 from sqlalchemy.orm.sync import ONETOMANY, MANYTOONE
 import testbase
index d8ae77408178d51df0396e3a561d0f4f11ee1e14..1437cde1fbcdfd1d21d65708a8dc883e08cd2545 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 
 class O2MTest(testbase.ORMTest):
index af5b7da0ea7871a3372bcfe7739138c221fdc106..d0d03210bf482a08943e93b87a9017f0e5a551aa 100644 (file)
@@ -1,6 +1,7 @@
 from sqlalchemy import *
 from sqlalchemy.orm import *
 import testbase
+from testbase import Table, Column
 
 class ConcreteTest1(testbase.ORMTest):
     def define_tables(self, metadata):
@@ -64,4 +65,4 @@ class ConcreteTest1(testbase.ORMTest):
 
 
 if __name__ == '__main__':
-    testbase.main()
\ No newline at end of file
+    testbase.main()
index 880ede591876734e1ac1c3d2e093f3d1adeb913e..60d690388c3d6a352d1f9d4e1ef0e455f9f033f1 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 
 class BaseObject(object):
index 9571ccf2fc5a15b303a3c55fb6b28f53937b2b71..97885c1b087483ff21c67a95f1ee2a44dd928af0 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 
 class InheritTest(testbase.ORMTest):
index 406981e7a43fa2d268585c15aa888455234f7a1a..a9482f28c919c9a1bc6d19f854f084bff46ddce1 100644 (file)
@@ -1,6 +1,8 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
+
 
 class PolymorphicCircularTest(testbase.ORMTest):
     keep_mappers = True
index b166cc19d67502cf57f5ae372a4c0d12caa92f13..0fadfa1950dbd8a24b5146be69528d88775f7969 100644 (file)
@@ -1,10 +1,11 @@
+"""tests basic polymorphic mapper loading/saving, minimal relations"""
+
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
-
+from testbase import Table, Column
 import sets
 
-# tests basic polymorphic mapper loading/saving, minimal relations
 
 class Person(object):
     def __init__(self, **kwargs):
index a678994493d66974e433b702a76863bd5f9d8ab5..664fb78a38c51adaf427d3169aa1d4f8b1e5883c 100644 (file)
@@ -1,8 +1,9 @@
 from sqlalchemy import *
 from sqlalchemy.orm import *
-
+from testbase import Table, Column
 import testbase
 
+
 class AttrSettable(object):
     def __init__(self, **kwargs):
         [setattr(self, k, v) for k, v in kwargs.iteritems()]
index 510f9ec8b6ebfbe82c857703d5c8305060432a7b..aff89f5b77c65cdc4b59c5bf3d80ef4f79e9d937 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
 from datetime import datetime
 
index 87ee0e57c0b46f138d246444b7f2bcec2bc6409d..1839f3b0368e492d2ccf206682f77c202fce8aa2 100644 (file)
@@ -1,8 +1,9 @@
 from sqlalchemy import *
 from sqlalchemy.orm import *
-
+from testbase import Table, Column
 import testbase
 
+
 class SingleInheritanceTest(testbase.AssertMixin):
     def setUpAll(self):
         metadata = BoundMetaData(testbase.db)
@@ -62,4 +63,4 @@ class SingleInheritanceTest(testbase.AssertMixin):
         assert session.query(JuniorEngineer).select() == [e2]
         
 if __name__ == '__main__':
-    testbase.main()
\ No newline at end of file
+    testbase.main()
index 0a88785cda8ce4ba5f76e8ffcc56345f2b336333..d6c094ddd3550167497bc0a9837e157c32394ec5 100644 (file)
@@ -3,6 +3,7 @@ import testbase
 import unittest, sys, os
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 import datetime
 
 class LazyTest(AssertMixin):
index 01df54d8164d5ad653b9068ee19c858636060606..6a9bd2126c9432a7a1b06f1af0383f556162b99b 100644 (file)
@@ -1,6 +1,7 @@
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 import string
 
 class Place(object):
index e53890d69fecb0e5525a467fe14cb363340f7f39..04cc6d220b963d05053ad209eae789124c20bd7d 100644 (file)
@@ -4,6 +4,7 @@ from sqlalchemy.orm import mapperlib, session, unitofwork, attributes
 Mapper = mapperlib.Mapper
 import gc
 import testbase
+from testbase import Table, Column
 import tables
 
 class A(object):pass
index 41a755afb4ef67d117187f6f0defad72fbd60d43..66e21ed8d16b491f4c4ca843bd715baf26e9a9ca 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest, AssertMixin
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 from tables import *
 import tables
 
@@ -166,4 +167,4 @@ class MergeTest(AssertMixin):
 if __name__ == "__main__":    
     testbase.main()
 
-                
\ No newline at end of file
+                
index e78eddb093babf793d36c294b5ee9a387b089a4f..0f8ddd418834a43e712e8f3fe3801f9b1bb33ea9 100644 (file)
@@ -2,6 +2,7 @@ import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import *
 from sqlalchemy.ext.sessioncontext import SessionContext
+from testbase import Table, Column
 
 class Jack(object):
     def __repr__(self):
index 9527b25d834a0cef1799d050814b902d20a53f72..6b77224e8519ede09d3783c24284db475e1392b5 100644 (file)
@@ -1,6 +1,7 @@
 from sqlalchemy import *
 from sqlalchemy.orm import *
 import testbase
+from testbase import Table, Column
 from fixtures import *
 
 class Base(object):
index e5fd0dd328649e7844831b34a04357eacbdb7c34..e1197e8f7433441814a0907397a53b5b0e7e3e6b 100644 (file)
@@ -1,12 +1,10 @@
 import testbase
 import unittest, sys, datetime
-
-db = testbase.db
-#db. 
-
 from sqlalchemy import *
 from sqlalchemy.orm import *
+from testbase import Table, Column
 
+db = testbase.db
 
 class RelationTest(testbase.PersistTest):
     """this is essentially an extension of the "dependency.py" topological sort test.  
index 57615ed5833b7ea7c8759a179f295bb53aee0119..f6cd8f9f482a2c585ea6ca1482900c50b42ebdd2 100644 (file)
@@ -6,12 +6,12 @@ from sqlalchemy import *
 from sqlalchemy.orm import *
 
 import testbase
+from testbase import Table, Column
 
 metadata = MetaData()
 users = Table('users', metadata,
     Column('user_id', Integer, Sequence('user_id_seq', optional=True), primary_key = True),
     Column('user_name', String(40)),
-    mysql_engine='innodb'
 )
 
 class SessionContextTest(AssertMixin):
index 1dcd40236a815178a3f4e35f19607ac7dae77a18..eed8cc2fbced87ea128507f924e4a2267ad0cec1 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest, AssertMixin
 from sqlalchemy import *
 from sqlalchemy.orm import *
 import testbase
+from testbase import Table, Column
 import pickleable
 from sqlalchemy.orm.mapper import global_extensions
 from sqlalchemy.orm import util as ormutil
@@ -462,7 +463,7 @@ class PassiveDeletesTest(UnitOfWorkTest):
         mytable = Table('mytable', metadata,
             Column('id', Integer, primary_key=True),
             Column('data', String(30)),
-            mysql_engine='InnoDB'
+            test_need_fk=True,
             )
 
         myothertable = Table('myothertable', metadata,
@@ -470,7 +471,7 @@ class PassiveDeletesTest(UnitOfWorkTest):
             Column('parent_id', Integer),
             Column('data', String(30)),
             ForeignKeyConstraint(['parent_id'],['mytable.id'], ondelete="CASCADE"),
-            mysql_engine='InnoDB'
+            test_need_fk=True,
             )
 
         metadata.create_all()
index a09e9dd6f74e185af72ad33cd6f96663df1477f3..fb3fb79709d8f3ee68dbf9c8568369e4f874742e 100644 (file)
@@ -1,4 +1,5 @@
 from sqlalchemy import *
+from testbase import Table, Column
 from timeit import Timer
 import sys
 
@@ -87,4 +88,4 @@ if __name__ == "__main__":
 
     print "\nCreate backward associations"
     create_it = tt.create_back_assoc
-    tt.run(10)
\ No newline at end of file
+    tt.run(10)
index d4076f5ba91382e13df8df7617fb8d98e8670f07..dc3416089f6c3bb00903966f69f9bd0d1ffd6f45 100644 (file)
@@ -1,6 +1,7 @@
 from testbase import PersistTest, AssertMixin
 import unittest, sys, os
 from sqlalchemy import *
+from testbase import Table, Column
 import StringIO
 import testbase
 import gc
index 9cbabea17a7420b675e6317a11e9d383d8a93eef..560696f511cff546b7c29921ba0684f42ad3a075 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest, AssertMixin
 import unittest, sys, os
 from sqlalchemy import *
 import sqlalchemy.orm.attributes as attributes
+from testbase import Table, Column
 import StringIO
 import testbase
 import gc
index 1506ca5030e81c82064b97168bd8087652b57b80..d6424eb0739f6e6f5e83d769f442afadd8f87dc2 100644 (file)
@@ -7,6 +7,7 @@ try:
 except:
     pass
 from sqlalchemy import *
+from testbase import Table, Column
 import time
 
 metadata = create_engine('sqlite://', echo=True)
index 8e4d5e3fff5cbe1d228d5207ef9eb00ac234a71c..98917462e8475c71cfa9648ed75bcf066e2a05db 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest, AssertMixin
 import unittest, sys, os
 from sqlalchemy import *
 import sqlalchemy.attributes as attributes
+from testbase import Table, Column
 import StringIO
 import testbase
 import gc
index 1b130f568bd1633d278a3e65658d97ebe7d47190..29dcf87e92c683b0991c965b8772850dd7389bb2 100644 (file)
@@ -4,6 +4,7 @@
 
 from sqlalchemy import *
 import sqlalchemy.pool as pool
+from testbase import Table, Column
 import psycopg2 as psycopg
 import thread,time
 psycopg = pool.manage(psycopg,pool_size=2,max_overflow=1, timeout=5, echo=True)
@@ -33,4 +34,4 @@ for x in range(0,50):
     thread.start_new_thread(run, ())
 
 while True:
-    time.sleep(5)
\ No newline at end of file
+    time.sleep(5)
index 3c521f231680e6a97465859af020d64e0d3825d0..01418d280223231c8d31fb2c8f1c90ed8ee34863 100644 (file)
@@ -3,6 +3,7 @@
 from sqlalchemy import *
 import thread, time, random
 from sqlalchemy.orm import mapperlib
+from testbase import Table, Column
 
 meta = BoundMetaData('sqlite:///foo.db')
 
index 7068de1fdeda77284e073dfb62a1cd8e74d0cd7a..b77742d78fc05a953f3979bf7b2d58ce271223a2 100644 (file)
@@ -4,6 +4,7 @@ from sqlalchemy import *
 import sqlalchemy.pool as pool
 import thread
 from sqlalchemy import exceptions
+from testbase import Table, Column
 
 import logging
 logging.basicConfig()
index 186547395143536e8522cc2b3c315accef4476e3..802de6231ecc02526de643674f96d2dfcec0c1d0 100644 (file)
@@ -1,6 +1,7 @@
 import sys
 import testbase
 from sqlalchemy import *
+from testbase import Table, Column
 
 
 class CaseTest(testbase.PersistTest):
index d695e824c757989d74ed5daff15b5ccbfee54f2c..d84901a48ced1e85c74dd4a6c8171bd18ae13f78 100644 (file)
@@ -1,5 +1,6 @@
 import testbase
 from sqlalchemy import *
+from testbase import Table, Column
 import sys
 
 class ConstraintTest(testbase.AssertMixin):
index d4cb9e9f362d0f397fabf754d7ced5ba0cfe34d5..94adaa11d4ec016b675ebffe1edce280efd5fd6e 100644 (file)
@@ -5,6 +5,7 @@ import sqlalchemy.schema as schema
 import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import mapper, create_session
+from testbase import Table, Column
 import sqlalchemy
 
 db = testbase.db
index ee9fa6bc50f029e202d1bbbd77edffbe2b7b5b2c..968e75dfc330d319aacdc83ce77d4ef747748dcb 100644 (file)
@@ -1,6 +1,6 @@
 import testbase
-
 from sqlalchemy import *
+from testbase import Table, Column
 
 # TODO: either create a mock dialect with named paramstyle and a short identifier length,
 # or find a way to just use sqlite dialect and make those changes
index 0d12aa19399b6e8458618c34a80d4343c2df6b4a..8597fbe75670796fcecb5dcdda5f3765ea56425c 100644 (file)
@@ -8,6 +8,8 @@ import tables
 from sqlalchemy import *
 from sqlalchemy.engine import ResultProxy, RowProxy
 from sqlalchemy import exceptions
+from testbase import Table, Column
+
 
 class QueryTest(PersistTest):
     
index 5259437fc748a03994268f59ce0fbd2b4a12a7db..1281b3d1ab173ff855c2baa52f3afa34a7261678 100644 (file)
@@ -1,6 +1,8 @@
 from testbase import PersistTest
 import testbase
 from sqlalchemy import *
+from testbase import Table, Column
+
 
 class QuoteTest(PersistTest):
     def setUpAll(self):
index 95cab898c3cd223deef184ebe2b2ff2132774a17..673a51bb0e3292b952b4d0b3b402d8da7d12d631 100644 (file)
@@ -1,6 +1,8 @@
 from sqlalchemy import *
+from testbase import Table, Column
 import testbase
 
+
 class FoundRowsTest(testbase.AssertMixin):
     """tests rowcount functionality"""
     def setUpAll(self):
index 557527d056ee150fe67f94947f4deb9f40c319d5..157c62300052135e1424cd8b1c8f558f6d1f11e7 100644 (file)
@@ -2,6 +2,7 @@ from testbase import PersistTest
 import testbase
 from sqlalchemy import *
 from sqlalchemy.databases import sqlite, postgres, mysql, oracle, firebird, mssql
+from testbase import Table, Column
 import unittest, re, operator
 
 
index b7ab91ee8fbbd6c0d236c5d99bf154e742ce6c99..dc992399e97398f9b39e87eae6f2950864931761 100755 (executable)
-"""tests that various From objects properly export their columns, as well as useable primary keys\r
-and foreign keys.  Full relational algebra depends on every selectable unit behaving\r
-nicely with others.."""\r
-\r
-import testbase\r
-import unittest, sys, datetime\r
-\r
-\r
-db = testbase.db\r
-\r
-from sqlalchemy import *\r
-\r
-metadata = BoundMetaData(db)\r
-table = Table('table1', metadata, \r
-    Column('col1', Integer, primary_key=True),\r
-    Column('col2', String(20)),\r
-    Column('col3', Integer),\r
-    Column('colx', Integer),\r
-    \r
-)\r
-\r
-table2 = Table('table2', metadata,\r
-    Column('col1', Integer, primary_key=True),\r
-    Column('col2', Integer, ForeignKey('table1.col1')),\r
-    Column('col3', String(20)),\r
-    Column('coly', Integer),\r
-)\r
-\r
-class SelectableTest(testbase.AssertMixin):\r
-    def testjoinagainstself(self):\r
-        jj = select([table.c.col1.label('bar_col1')])\r
-        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)\r
-        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1\r
-\r
-    def testjoinagainstjoin(self):\r
-        j  = outerjoin(table, table2, table.c.col1==table2.c.col2)\r
-        jj = select([ table.c.col1.label('bar_col1')],from_obj=[j]).alias('foo')\r
-        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)\r
-        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1\r
-        \r
-        \r
-    def testtablealias(self):\r
-        a = table.alias('a')\r
-        \r
-        j = join(a, table2)\r
-        \r
-        criterion = a.c.col1 == table2.c.col2\r
-        print\r
-        print str(j)\r
-        self.assert_(criterion.compare(j.onclause))\r
-\r
-    def testunion(self):\r
-        # tests that we can correspond a column in a Select statement with a certain Table, against\r
-        # a column in a Union where one of its underlying Selects matches to that same Table\r
-        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(\r
-                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])\r
-            )\r
-        s1 = table.select(use_labels=True)\r
-        s2 = table2.select(use_labels=True)\r
-        print ["%d %s" % (id(c),c.key) for c in u.c]\r
-        c = u.corresponding_column(s1.c.table1_col2)\r
-        print "%d %s" % (id(c), c.key)\r
-        assert u.corresponding_column(s1.c.table1_col2) is u.c.col2\r
-        assert u.corresponding_column(s2.c.table2_col2) is u.c.col2\r
-\r
-    def testaliasunion(self):\r
-        # same as testunion, except its an alias of the union\r
-        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(\r
-                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])\r
-            ).alias('analias')\r
-        s1 = table.select(use_labels=True)\r
-        s2 = table2.select(use_labels=True)\r
-        assert u.corresponding_column(s1.c.table1_col2) is u.c.col2\r
-        assert u.corresponding_column(s2.c.table2_col2) is u.c.col2\r
-        assert u.corresponding_column(s2.c.table2_coly) is u.c.coly\r
-        assert s2.corresponding_column(u.c.coly) is s2.c.table2_coly\r
-\r
-    def testselectunion(self):\r
-        # like testaliasunion, but off a Select off the union.\r
-        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(\r
-                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])\r
-            ).alias('analias')\r
-        s = select([u])\r
-        s1 = table.select(use_labels=True)\r
-        s2 = table2.select(use_labels=True)\r
-        assert s.corresponding_column(s1.c.table1_col2) is s.c.col2\r
-        assert s.corresponding_column(s2.c.table2_col2) is s.c.col2\r
-\r
-    def testunionagainstjoin(self):\r
-        # same as testunion, except its an alias of the union\r
-        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(\r
-                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])\r
-            ).alias('analias')\r
-        j1 = table.join(table2)\r
-        assert u.corresponding_column(j1.c.table1_colx) is u.c.colx\r
-        assert j1.corresponding_column(u.c.colx) is j1.c.table1_colx\r
-        \r
-    def testjoin(self):\r
-        a = join(table, table2)\r
-        print str(a.select(use_labels=True))\r
-        b = table2.alias('b')\r
-        j = join(a, b)\r
-        print str(j)\r
-        criterion = a.c.table1_col1 == b.c.col2\r
-        self.assert_(criterion.compare(j.onclause))\r
-\r
-    def testselectalias(self):\r
-        a = table.select().alias('a')\r
-        print str(a.select())\r
-        j = join(a, table2)\r
-        \r
-        criterion = a.c.col1 == table2.c.col2\r
-        print\r
-        print str(j)\r
-        self.assert_(criterion.compare(j.onclause))\r
-\r
-    def testselectlabels(self):\r
-        a = table.select(use_labels=True)\r
-        print str(a.select())\r
-        j = join(a, table2)\r
-        \r
-        criterion = a.c.table1_col1 == table2.c.col2\r
-        print\r
-        print str(j)\r
-        self.assert_(criterion.compare(j.onclause))\r
-\r
-    def testcolumnlabels(self):\r
-        a = select([table.c.col1.label('acol1'), table.c.col2.label('acol2'), table.c.col3.label('acol3')])\r
-        print str(a)\r
-        print [c for c in a.columns]\r
-        print str(a.select())\r
-        j = join(a, table2)\r
-        criterion = a.c.acol1 == table2.c.col2\r
-        print str(j)\r
-        self.assert_(criterion.compare(j.onclause))\r
-        \r
-    def testselectaliaslabels(self):\r
-        a = table2.select(use_labels=True).alias('a')\r
-        print str(a.select())\r
-        j = join(a, table)\r
-        \r
-        criterion =  table.c.col1 == a.c.table2_col2\r
-        print str(criterion)\r
-        print str(j.onclause)\r
-        self.assert_(criterion.compare(j.onclause))\r
-        \r
-if __name__ == "__main__":\r
-    testbase.main()\r
-    
\ No newline at end of file
+"""tests that various From objects properly export their columns, as well as
+useable primary keys and foreign keys.  Full relational algebra depends on
+every selectable unit behaving nicely with others.."""
+
+import testbase
+import unittest, sys, datetime
+from sqlalchemy import *
+from testbase import Table, Column
+
+
+db = testbase.db
+metadata = BoundMetaData(db)
+table = Table('table1', metadata, 
+    Column('col1', Integer, primary_key=True),
+    Column('col2', String(20)),
+    Column('col3', Integer),
+    Column('colx', Integer),
+    
+)
+
+table2 = Table('table2', metadata,
+    Column('col1', Integer, primary_key=True),
+    Column('col2', Integer, ForeignKey('table1.col1')),
+    Column('col3', String(20)),
+    Column('coly', Integer),
+)
+
+class SelectableTest(testbase.AssertMixin):
+    def testjoinagainstself(self):
+        jj = select([table.c.col1.label('bar_col1')])
+        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)
+        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1
+
+    def testjoinagainstjoin(self):
+        j  = outerjoin(table, table2, table.c.col1==table2.c.col2)
+        jj = select([ table.c.col1.label('bar_col1')],from_obj=[j]).alias('foo')
+        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)
+        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1
+        
+        
+    def testtablealias(self):
+        a = table.alias('a')
+        
+        j = join(a, table2)
+        
+        criterion = a.c.col1 == table2.c.col2
+        print
+        print str(j)
+        self.assert_(criterion.compare(j.onclause))
+
+    def testunion(self):
+        # tests that we can correspond a column in a Select statement with a certain Table, against
+        # a column in a Union where one of its underlying Selects matches to that same Table
+        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(
+                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])
+            )
+        s1 = table.select(use_labels=True)
+        s2 = table2.select(use_labels=True)
+        print ["%d %s" % (id(c),c.key) for c in u.c]
+        c = u.corresponding_column(s1.c.table1_col2)
+        print "%d %s" % (id(c), c.key)
+        assert u.corresponding_column(s1.c.table1_col2) is u.c.col2
+        assert u.corresponding_column(s2.c.table2_col2) is u.c.col2
+
+    def testaliasunion(self):
+        # same as testunion, except its an alias of the union
+        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(
+                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])
+            ).alias('analias')
+        s1 = table.select(use_labels=True)
+        s2 = table2.select(use_labels=True)
+        assert u.corresponding_column(s1.c.table1_col2) is u.c.col2
+        assert u.corresponding_column(s2.c.table2_col2) is u.c.col2
+        assert u.corresponding_column(s2.c.table2_coly) is u.c.coly
+        assert s2.corresponding_column(u.c.coly) is s2.c.table2_coly
+
+    def testselectunion(self):
+        # like testaliasunion, but off a Select off the union.
+        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(
+                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])
+            ).alias('analias')
+        s = select([u])
+        s1 = table.select(use_labels=True)
+        s2 = table2.select(use_labels=True)
+        assert s.corresponding_column(s1.c.table1_col2) is s.c.col2
+        assert s.corresponding_column(s2.c.table2_col2) is s.c.col2
+
+    def testunionagainstjoin(self):
+        # same as testunion, except its an alias of the union
+        u = select([table.c.col1, table.c.col2, table.c.col3, table.c.colx, null().label('coly')]).union(
+                select([table2.c.col1, table2.c.col2, table2.c.col3, null().label('colx'), table2.c.coly])
+            ).alias('analias')
+        j1 = table.join(table2)
+        assert u.corresponding_column(j1.c.table1_colx) is u.c.colx
+        assert j1.corresponding_column(u.c.colx) is j1.c.table1_colx
+        
+    def testjoin(self):
+        a = join(table, table2)
+        print str(a.select(use_labels=True))
+        b = table2.alias('b')
+        j = join(a, b)
+        print str(j)
+        criterion = a.c.table1_col1 == b.c.col2
+        self.assert_(criterion.compare(j.onclause))
+
+    def testselectalias(self):
+        a = table.select().alias('a')
+        print str(a.select())
+        j = join(a, table2)
+        
+        criterion = a.c.col1 == table2.c.col2
+        print
+        print str(j)
+        self.assert_(criterion.compare(j.onclause))
+
+    def testselectlabels(self):
+        a = table.select(use_labels=True)
+        print str(a.select())
+        j = join(a, table2)
+        
+        criterion = a.c.table1_col1 == table2.c.col2
+        print
+        print str(j)
+        self.assert_(criterion.compare(j.onclause))
+
+    def testcolumnlabels(self):
+        a = select([table.c.col1.label('acol1'), table.c.col2.label('acol2'), table.c.col3.label('acol3')])
+        print str(a)
+        print [c for c in a.columns]
+        print str(a.select())
+        j = join(a, table2)
+        criterion = a.c.acol1 == table2.c.col2
+        print str(j)
+        self.assert_(criterion.compare(j.onclause))
+        
+    def testselectaliaslabels(self):
+        a = table2.select(use_labels=True).alias('a')
+        print str(a.select())
+        j = join(a, table)
+        
+        criterion =  table.c.col1 == a.c.table2_col2
+        print str(criterion)
+        print str(j.onclause)
+        self.assert_(criterion.compare(j.onclause))
+        
+if __name__ == "__main__":
+    testbase.main()
+    
index 8406860ee7ceb34c49a284a70b56d638d1fa2a50..5e272cfc939b0589f482ea50f7dbb28ca1fcb987 100644 (file)
@@ -4,9 +4,10 @@ import pickleable
 from sqlalchemy import *
 import string,datetime, re, sys, os
 import sqlalchemy.engine.url as url
-
 import sqlalchemy.types
 from sqlalchemy.databases import mssql, oracle
+from testbase import Table, Column
+
 
 db = testbase.db
 
index 15f4dd14c3eeaf2d286afc0937962a2ceae8537b..fb77a77b749131e4f336936edecde4c381b96b5c 100644 (file)
@@ -1,10 +1,11 @@
 # coding: utf-8
-import testbase
+"""verrrrry basic unicode column name testing"""
 
+import testbase
 from sqlalchemy import *
 from sqlalchemy.orm import mapper, relation, create_session, eagerload
+from testbase import Table, Column
 
-"""verrrrry basic unicode column name testing"""
 
 class UnicodeSchemaTest(testbase.PersistTest):
     def setUpAll(self):
index 8f00ea6acd4b1fe88185fce7affa76ead607b100..33ba858c2161b40389aaec7b9a629dc232374ccc 100644 (file)
@@ -2,7 +2,7 @@
 from sqlalchemy import *
 import os
 import testbase
-
+from testbase import Table, Column
 
 ECHO = testbase.echo
 db = testbase.db
@@ -11,14 +11,14 @@ metadata = BoundMetaData(db)
 users = Table('users', metadata,
     Column('user_id', Integer, Sequence('user_id_seq', optional=True), primary_key = True),
     Column('user_name', String(40)),
-    mysql_engine='innodb'
+    test_needs_acid=True,
+    test_needs_fk=True,
 )
 
 addresses = Table('email_addresses', metadata,
     Column('address_id', Integer, Sequence('address_id_seq', optional=True), primary_key = True),
     Column('user_id', Integer, ForeignKey(users.c.user_id)),
     Column('email_address', String(40)),
-    
 )
 
 orders = Table('orders', metadata,
@@ -26,20 +26,17 @@ orders = Table('orders', metadata,
     Column('user_id', Integer, ForeignKey(users.c.user_id)),
     Column('description', String(50)),
     Column('isopen', Integer),
-    
 )
 
 orderitems = Table('items', metadata,
     Column('item_id', INT, Sequence('items_id_seq', optional=True), primary_key = True),
     Column('order_id', INT, ForeignKey("orders")),
     Column('item_name', VARCHAR(50)),
-    
 )
 
 keywords = Table('keywords', metadata,
     Column('keyword_id', Integer, Sequence('keyword_id_seq', optional=True), primary_key = True),
     Column('name', VARCHAR(50)),
-    
 )
 
 userkeywords = Table('userkeywords', metadata, 
index 29c5c8ff3419d401c09a7036a31a31c9f0181ebd..4e3fc2d6595e2ac84ce7c2e17a4aec90866863a2 100644 (file)
@@ -7,13 +7,14 @@ import sys
 import os, unittest, StringIO, re, ConfigParser, optparse
 sys.path.insert(0, os.path.join(os.getcwd(), 'lib'))
 import sqlalchemy
-from sqlalchemy import sql, engine, pool, BoundMetaData
+from sqlalchemy import sql, schema, engine, pool, BoundMetaData
 from sqlalchemy.orm import clear_mappers
 
 db = None
 metadata = None
 db_uri = None
 echo = True
+table_options = {}
 
 # redefine sys.stdout so all those print statements go to the echo func
 local_stdout = sys.stdout
@@ -64,6 +65,8 @@ firebird=firebird://sysdba:s@localhost/tmp/test.fdb
     parser.add_option("--reversetop", action="store_true", dest="topological", help="Reverse the collection ordering for topological sorts (helps reveal dependency issues)")
     parser.add_option("--serverside", action="store_true", dest="serverside", help="Turn on server side cursors for PG")
     parser.add_option("--require", action="append", dest="require", help="Require a particular driver or module version", default=[])
+    parser.add_option("--mysql-engine", action="store", dest="mysql_engine", help="Use the specified MySQL storage engine for all tables, default is a db-default/InnoDB combo.", default=None)
+    parser.add_option("--table-option", action="append", dest="tableopts", help="Add a dialect-specific table option, key=value", default=[])
     
     (options, args) = parser.parse_args()
     sys.argv[1:] = args
@@ -106,6 +109,14 @@ firebird=firebird://sysdba:s@localhost/tmp/test.fdb
     if not db_uri:
         raise "Could not create engine.  specify --db <sqlite|sqlite_file|postgres|mysql|oracle|oracle8|mssql|firebird> to test runner."
 
+    global table_options
+    for spec in options.tableopts:
+        key, value = spec.split('=')
+        table_options[key] = value
+
+    if options.mysql_engine:
+        table_options['mysql_engine'] = options.mysql_engine
+
     if not options.nothreadlocal:
         __import__('sqlalchemy.mods.threadlocal')
         sqlalchemy.mods.threadlocal.uninstall_plugin()
@@ -188,6 +199,27 @@ def supported(*dbs):
             return lala
     return decorate
 
+def Table(*args, **kw):
+    """A schema.Table wrapper/hook for dialect-specific tweaks."""
+
+    test_opts = dict([(k,kw.pop(k)) for k in kw.keys()
+                      if k.startswith('test_')])
+
+    kw.update(table_options)
+
+    if db.engine.name == 'mysql':
+        if 'mysql_engine' not in kw and 'mysql_type' not in kw:
+            if 'test_needs_fk' in test_opts or 'test_needs_acid' in test_opts:
+                kw['mysql_engine'] = 'InnoDB'
+
+    return schema.Table(*args, **kw)
+
+def Column(*args, **kw):
+    """A schema.Column wrapper/hook for dialect-specific tweaks."""
+
+    # TODO: a Column that creates a Sequence automatically for PK columns,
+    # which would help Oracle tests
+    return schema.Column(*args, **kw)
         
 class PersistTest(unittest.TestCase):
 
index f01f18921b46fcd847fa2376a43d9288109ce55d..0ca66fb7227c69ac30574a56aed02c4258e636e4 100644 (file)
@@ -1,4 +1,5 @@
 from sqlalchemy import *
+from testbase import Table, Column
 
 metadata = MetaData()
 """application table metadata objects are described here."""