]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix to types test, postgres time types descend from Time type
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Feb 2006 04:49:04 +0000 (04:49 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Feb 2006 04:49:04 +0000 (04:49 +0000)
lib/sqlalchemy/databases/postgres.py
test/alltests.py
test/testtypes.py [moved from test/types.py with 89% similarity]

index dab14b460d0c75a8c08a429507373a1118dee1c4..d93a084ee560d1c419cf85e7b0dbf6d1fe865c8c 100644 (file)
@@ -62,10 +62,10 @@ class PG1Date(sqltypes.Date):
         return value
     def get_col_spec(self):
         return "DATE"
-class PG2Time(sqltypes.Date):
+class PG2Time(sqltypes.Time):
     def get_col_spec(self):
         return "TIME"
-class PG1Time(sqltypes.Date):
+class PG1Time(sqltypes.Time):
     def convert_bind_param(self, value, engine):
         # TODO: perform appropriate postgres1 conversion between Python DateTime/MXDateTime
         # this one doesnt seem to work with the "emulation" mode
index 83b1647318adbd82d1f0c568796cc44ad036b154..3fe704e93f575338d62666cb3505328ade3d7f29 100644 (file)
@@ -15,7 +15,7 @@ def suite():
         
         # schema/tables
         'engines', 
-        'types',
+        'testtypes',
         
         # SQL syntax
         'select',
@@ -46,7 +46,6 @@ def suite():
         #'wsgi_test',
         
         )
-
     alltests = unittest.TestSuite()
     for module in map(__import__, modules_to_test):
         alltests.addTest(unittest.findTestCases(module, suiteClass=None))
similarity index 89%
rename from test/types.py
rename to test/testtypes.py
index 77452e51b1670cfe84f8867aba1337daa162117d..3ea868ac90461f578567c981fd21f9ede9cd8fcd 100644 (file)
@@ -5,30 +5,41 @@ import testbase
     
 db = testbase.db
 
+class MyType(types.TypeEngine):
+    def get_col_spec(self):
+        return "VARCHAR(100)"
+    def convert_bind_param(self, value, engine):
+        return "BIND_IN"+ value
+    def convert_result_value(self, value, engine):
+        return value + "BIND_OUT"
+    def adapt(self, typeobj):
+        return typeobj()
+    def adapt_args(self):
+        return self
+
+class MyDecoratedType(types.TypeDecorator, types.String):
+    def convert_bind_param(self, value, engine):
+        return "BIND_IN"+ value
+    def convert_result_value(self, value, engine):
+        return value + "BIND_OUT"
+
 class OverrideTest(PersistTest):
     """tests user-defined types, including a full type as well as a TypeDecorator"""
 
     def testprocessing(self):
-        class MyType(types.TypeEngine):
-            def get_col_spec(self):
-                return "VARCHAR(100)"
-            def convert_bind_param(self, value, engine):
-                return "BIND_IN"+ value
-            def convert_result_value(self, value, engine):
-                return value + "BIND_OUT"
-            def adapt(self, typeobj):
-                return typeobj()
-            def adapt_args(self):
-                return self
-
-        class MyDecoratedType(types.TypeDecorator, types.String):
-            def convert_bind_param(self, value, engine):
-                return "BIND_IN"+ value
-            def convert_result_value(self, value, engine):
-                return value + "BIND_OUT"
 
         global users
-        users = Table('users', db, 
+        users.insert().execute(user_id = 2, goofy = 'jack', goofy2='jack', goofy3='jack')
+        users.insert().execute(user_id = 3, goofy = 'lala', goofy2='lala', goofy3='lala')
+        users.insert().execute(user_id = 4, goofy = 'fred', goofy2='fred', goofy3='fred')
+        
+        l = users.select().execute().fetchall()
+        print repr(l)
+        self.assert_(l == [(2, 'BIND_INjackBIND_OUT', 'BIND_INjackBIND_OUT', 'BIND_INjackBIND_OUT'), (3, 'BIND_INlalaBIND_OUT', 'BIND_INlalaBIND_OUT', 'BIND_INlalaBIND_OUT'), (4, 'BIND_INfredBIND_OUT', 'BIND_INfredBIND_OUT', 'BIND_INfredBIND_OUT')])
+
+    def setUpAll(self):
+        global users
+        users = Table('type_users', db, 
             Column('user_id', Integer, primary_key = True),
             # totall custom type
             Column('goofy', MyType, nullable = False),
@@ -41,16 +52,6 @@ class OverrideTest(PersistTest):
         )
         
         users.create()
-        
-        users.insert().execute(user_id = 2, goofy = 'jack', goofy2='jack', goofy3='jack')
-        users.insert().execute(user_id = 3, goofy = 'lala', goofy2='lala', goofy3='lala')
-        users.insert().execute(user_id = 4, goofy = 'fred', goofy2='fred', goofy3='fred')
-        
-        l = users.select().execute().fetchall()
-        print repr(l)
-        self.assert_(l == [(2, 'BIND_INjackBIND_OUT', 'BIND_INjackBIND_OUT', 'BIND_INjackBIND_OUT'), (3, 'BIND_INlalaBIND_OUT', 'BIND_INlalaBIND_OUT', 'BIND_INlalaBIND_OUT'), (4, 'BIND_INfredBIND_OUT', 'BIND_INfredBIND_OUT', 'BIND_INfredBIND_OUT')])
-
-
     def tearDownAll(self):
         global users
         users.drop()
@@ -79,7 +80,7 @@ class ColumnsTest(AssertMixin):
         )
 
         for aCol in testTable.c:
-            self.assertEquals(expectedResults[aCol.name], db.schemagenerator(None).get_column_specification(aCol))
+            self.assertEquals(expectedResults[aCol.name], db.schemagenerator().get_column_specification(aCol))
         
 class UnicodeTest(AssertMixin):
     """tests the Unicode type.  also tests the TypeDecorator with instances in the types package."""
@@ -87,8 +88,8 @@ class UnicodeTest(AssertMixin):
         global unicode_table
         unicode_table = Table('unicode_table', db, 
             Column('id', Integer, primary_key=True),
-            Column('unicode_data', Unicode(50)),
-            Column('plain_data', String)
+            Column('unicode_data', Unicode(250)),
+            Column('plain_data', String(250))
             )
         unicode_table.create()
     def tearDownAll(self):