summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--adbh.py2
-rw-r--r--test/unittest_adbh.py34
2 files changed, 36 insertions, 0 deletions
diff --git a/adbh.py b/adbh.py
index 7aeb1e4..7374172 100644
--- a/adbh.py
+++ b/adbh.py
@@ -465,6 +465,8 @@ class _MyAdvFuncHelper(_GenericAdvFuncHelper):
TYPE_MAPPING['Password'] = 'tinyblob'
TYPE_MAPPING['String'] = 'mediumtext'
TYPE_MAPPING['Bytes'] = 'longblob'
+ # don't use timestamp which is automatically updated on row update
+ TYPE_MAPPING['Datetime'] = 'datetime'
def system_database(self):
"""return the system database for the given driver"""
diff --git a/test/unittest_adbh.py b/test/unittest_adbh.py
new file mode 100644
index 0000000..5c054d2
--- /dev/null
+++ b/test/unittest_adbh.py
@@ -0,0 +1,34 @@
+
+from logilab.common.testlib import TestCase, unittest_main
+
+from logilab.common.adbh import get_adv_func_helper
+
+
+class PGHelperTC(TestCase):
+ driver = 'postgres'
+ def setUp(self):
+ self.helper = get_adv_func_helper(self.driver)
+
+ def test_type_map(self):
+ self.assertEquals(self.helper.TYPE_MAPPING['Datetime'], 'timestamp')
+ self.assertEquals(self.helper.TYPE_MAPPING['String'], 'text')
+ self.assertEquals(self.helper.TYPE_MAPPING['Password'], 'bytea')
+ self.assertEquals(self.helper.TYPE_MAPPING['Bytes'], 'bytea')
+
+
+class SQLITEHelperTC(PGHelperTC):
+ driver = 'sqlite'
+
+
+class MYHelperTC(PGHelperTC):
+ driver = 'mysql'
+
+ def test_type_map(self):
+ self.assertEquals(self.helper.TYPE_MAPPING['Datetime'], 'datetime')
+ self.assertEquals(self.helper.TYPE_MAPPING['String'], 'mediumtext')
+ self.assertEquals(self.helper.TYPE_MAPPING['Password'], 'tinyblob')
+ self.assertEquals(self.helper.TYPE_MAPPING['Bytes'], 'longblob')
+
+
+if __name__ == '__main__':
+ unittest_main()