summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 89a9522)
raw | patch | inline | side by side (parent: 89a9522)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 27 Jul 2001 06:55:07 +0000 (06:55 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 27 Jul 2001 06:55:07 +0000 (06:55 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@97 57a73879-2fb5-44c3-a270-3262357dd7e2
test/.cvsignore | [new file with mode: 0644] | patch | blob |
test/README.TXT | [new file with mode: 0644] | patch | blob |
test/__init__.py | [new file with mode: 0644] | patch | blob |
test/test_dates.py | [new file with mode: 0644] | patch | blob |
test/test_db.py | [new file with mode: 0644] | patch | blob |
test/test_schema.py | [new file with mode: 0644] | patch | blob |
tests/README.TXT | [deleted file] | patch | blob | history |
tests/__init__.py | [deleted file] | patch | blob | history |
tests/test_dates.py | [deleted file] | patch | blob | history |
tests/test_db.py | [deleted file] | patch | blob | history |
tests/test_schema.py | [deleted file] | patch | blob | history |
diff --git a/test/.cvsignore b/test/.cvsignore
--- /dev/null
+++ b/test/.cvsignore
@@ -0,0 +1,3 @@
+*.pyc
+localconfig.py
+db
diff --git a/test/README.TXT b/test/README.TXT
--- /dev/null
+++ b/test/README.TXT
@@ -0,0 +1,26 @@
+$Id: README.TXT,v 1.1 2001-07-27 06:55:07 richard Exp $
+
+Structre of the tests:
+
+ 1 Test date classes
+ 1.1 Date
+ 1.2 Interval
+ 2 Set up schema
+ 3 Open with specific backend
+ 3.1 anydbm
+ 3.2 bsddb
+ 4 Create database base set (stati, priority, etc)
+ 5 Perform some actions
+ 6 Perform mail import
+ 6.1 text/plain
+ 6.2 multipart/mixed (with one text/plain)
+ 6.3 text/html
+ 6.4 multipart/alternative (with one text/plain)
+ 6.5 multipart/alternative (with no text/plain)
+
+
+------
+$Log: not supported by cvs2svn $
+Revision 1.2 2001/07/25 04:34:31 richard
+Added id and log to tests files...
+
diff --git a/test/__init__.py b/test/__init__.py
--- /dev/null
+++ b/test/__init__.py
@@ -0,0 +1,21 @@
+# $Id: __init__.py,v 1.1 2001-07-27 06:55:07 richard Exp $
+
+import unittest
+
+import test_dates, test_schema, test_db
+
+def go():
+ suite = unittest.TestSuite((
+ test_dates.suite(),
+ test_schema.suite(),
+ test_db.suite(),
+ ))
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
+#
+# $Log: not supported by cvs2svn $
+# Revision 1.3 2001/07/25 04:34:31 richard
+# Added id and log to tests files...
+#
+#
diff --git a/test/test_dates.py b/test/test_dates.py
--- /dev/null
+++ b/test/test_dates.py
@@ -0,0 +1,62 @@
+# $Id: test_dates.py,v 1.1 2001-07-27 06:55:07 richard Exp $
+
+import unittest, time
+
+from roundup.date import Date, Interval
+
+class DateTestCase(unittest.TestCase):
+ def testDateInterval(self):
+ date = Date("2000-06-26.00:34:02 + 2d")
+ self.assertEqual(str(date), '2000-06-28.00:34:02')
+ date = Date("2000-02-27 + 2d")
+ self.assertEqual(str(date), '2000-02-29.00:00:00')
+ date = Date("2001-02-27 + 2d")
+ self.assertEqual(str(date), '2001-03-01.00:00:00')
+
+ def testDate(self):
+ date = Date("2000-04-17")
+ self.assertEqual(str(date), '2000-04-17.00:00:00')
+ date = Date("01-25")
+ y, m, d, x, x, x, x, x, x = time.gmtime()
+ self.assertEqual(str(date), '%s-01-25.00:00:00'%y)
+ date = Date("2000-04-17.03:45")
+ self.assertEqual(str(date), '2000-04-17.03:45:00')
+ date = Date("08-13.22:13")
+ self.assertEqual(str(date), '%s-08-13.22:13:00'%y)
+ date = Date("11-07.09:32:43")
+ self.assertEqual(str(date), '%s-11-07.09:32:43'%y)
+ date = Date("14:25")
+ self.assertEqual(str(date), '%s-%02d-%02d.14:25:00'%(y, m, d))
+ date = Date("8:47:11")
+ self.assertEqual(str(date), '%s-%02d-%02d.08:47:11'%(y, m, d))
+
+ def testOffset(self):
+ date = Date("2000-04-17", -5)
+ self.assertEqual(str(date), '2000-04-17.00:00:00')
+ date = Date("01-25", -5)
+ y, m, d, x, x, x, x, x, x = time.gmtime()
+ self.assertEqual(str(date), '%s-01-25.00:00:00'%y)
+ date = Date("2000-04-17.03:45", -5)
+ self.assertEqual(str(date), '2000-04-17.08:45:00')
+ date = Date("08-13.22:13", -5)
+ self.assertEqual(str(date), '%s-08-14.03:13:00'%y)
+ date = Date("11-07.09:32:43", -5)
+ self.assertEqual(str(date), '%s-11-07.14:32:43'%y)
+ date = Date("14:25", -5)
+ self.assertEqual(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
+ date = Date("8:47:11", -5)
+ self.assertEqual(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
+
+ def testInterval(self):
+ pass
+
+def suite():
+ return unittest.makeSuite(DateTestCase, 'test')
+
+
+#
+# $Log: not supported by cvs2svn $
+# Revision 1.2 2001/07/25 04:34:31 richard
+# Added id and log to tests files...
+#
+#
diff --git a/test/test_db.py b/test/test_db.py
--- /dev/null
+++ b/test/test_db.py
@@ -0,0 +1,172 @@
+# $Id: test_db.py,v 1.1 2001-07-27 06:55:07 richard Exp $
+
+import unittest, os, shutil
+
+from roundup.backends import anydbm
+from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class, \
+ DatabaseError
+
+def setupSchema(db, create):
+ status = Class(db, "status", name=String())
+ status.setkey("name")
+ if create:
+ status.create(name="unread")
+ status.create(name="in-progress")
+ status.create(name="testing")
+ status.create(name="resolved")
+ Class(db, "user", username=String(), password=String())
+ Class(db, "issue", title=String(), status=Link("status"),
+ nosy=Multilink("user"))
+
+class DBTestCase(unittest.TestCase):
+ def setUp(self):
+ class Database(anydbm.Database):
+ pass
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ self.db = Database('_test_dir', 'test')
+ setupSchema(self.db, 1)
+
+ def tearDown(self):
+ self.db.close()
+ shutil.rmtree('_test_dir')
+
+ def testChanges(self):
+ self.db.issue.create(title="spam", status='1')
+ self.db.issue.create(title="eggs", status='2')
+ self.db.issue.create(title="ham", status='4')
+ self.db.issue.create(title="arguments", status='2')
+ self.db.issue.create(title="abuse", status='1')
+ self.db.issue.addprop(fixer=Link("user"))
+ props = self.db.issue.getprops()
+ keys = props.keys()
+ keys.sort()
+ self.assertEqual(keys, ['fixer', 'nosy', 'status', 'title'])
+ self.db.issue.set('5', status='2')
+ self.db.issue.get('5', "status")
+ self.db.status.get('2', "name")
+ self.db.issue.get('5', "title")
+ self.db.issue.find(status = self.db.status.lookup("in-progress"))
+ self.db.issue.history('5')
+ self.db.status.history('1')
+ self.db.status.history('2')
+
+ def testExceptions(self):
+ # this tests the exceptions that should be raised
+ ar = self.assertRaises
+
+ #
+ # class create
+ #
+ # string property
+ ar(TypeError, self.db.status.create, name=1)
+ # invalid property name
+ ar(KeyError, self.db.status.create, foo='foo')
+ # key name clash
+ ar(ValueError, self.db.status.create, name='unread')
+ # invalid link index
+ ar(IndexError, self.db.issue.create, title='foo', status='bar')
+ # invalid link value
+ ar(ValueError, self.db.issue.create, title='foo', status=1)
+ # invalid multilink type
+ ar(TypeError, self.db.issue.create, title='foo', status='1',
+ nosy='hello')
+ # invalid multilink index type
+ ar(ValueError, self.db.issue.create, title='foo', status='1',
+ nosy=[1])
+ # invalid multilink index
+ ar(IndexError, self.db.issue.create, title='foo', status='1',
+ nosy=['10'])
+
+ #
+ # class get
+ #
+ # invalid node id
+ ar(IndexError, self.db.status.get, '10', 'name')
+ # invalid property name
+ ar(KeyError, self.db.status.get, '2', 'foo')
+
+ #
+ # class set
+ #
+ # invalid node id
+ ar(IndexError, self.db.issue.set, '1', name='foo')
+ # invalid property name
+ ar(KeyError, self.db.status.set, '1', foo='foo')
+ # string property
+ ar(TypeError, self.db.status.set, '1', name=1)
+ # key name clash
+ ar(ValueError, self.db.status.set, '2', name='unread')
+ # set up a valid issue for me to work on
+ self.db.issue.create(title="spam", status='1')
+ # invalid link index
+ ar(IndexError, self.db.issue.set, '1', title='foo', status='bar')
+ # invalid link value
+ ar(ValueError, self.db.issue.set, '1', title='foo', status=1)
+ # invalid multilink type
+ ar(TypeError, self.db.issue.set, '1', title='foo', status='1',
+ nosy='hello')
+ # invalid multilink index type
+ ar(ValueError, self.db.issue.set, '1', title='foo', status='1',
+ nosy=[1])
+ # invalid multilink index
+ ar(IndexError, self.db.issue.set, '1', title='foo', status='1',
+ nosy=['10'])
+
+ def testRetire(self):
+ ''' test retiring a node
+ '''
+ pass
+
+
+class ReadOnlyDBTestCase(unittest.TestCase):
+ def setUp(self):
+ class Database(anydbm.Database):
+ pass
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ db = Database('_test_dir', 'test')
+ setupSchema(db, 1)
+ db.close()
+ self.db = Database('_test_dir')
+ setupSchema(self.db, 0)
+
+ def tearDown(self):
+ self.db.close()
+ shutil.rmtree('_test_dir')
+
+ def testExceptions(self):
+ # this tests the exceptions that should be raised
+ ar = self.assertRaises
+
+ # this tests the exceptions that should be raised
+ ar(DatabaseError, self.db.status.create, name="foo")
+ ar(DatabaseError, self.db.status.set, '1', name="foo")
+ ar(DatabaseError, self.db.status.retire, '1')
+
+
+def suite():
+ db = unittest.makeSuite(DBTestCase, 'test')
+ readonlydb = unittest.makeSuite(ReadOnlyDBTestCase, 'test')
+ return unittest.TestSuite((db, readonlydb))
+
+
+#
+# $Log: not supported by cvs2svn $
+# Revision 1.7 2001/07/27 06:26:43 richard
+# oops - wasn't deleting the test dir after the read-only tests
+#
+# Revision 1.6 2001/07/27 06:23:59 richard
+# consistency
+#
+# Revision 1.5 2001/07/27 06:23:09 richard
+# Added some new hyperdb tests to make sure we raise the right exceptions.
+#
+# Revision 1.4 2001/07/25 04:34:31 richard
+# Added id and log to tests files...
+#
+#
diff --git a/test/test_schema.py b/test/test_schema.py
--- /dev/null
+++ b/test/test_schema.py
@@ -0,0 +1,64 @@
+# $Id: test_schema.py,v 1.1 2001-07-27 06:55:07 richard Exp $
+
+import unittest, os, shutil
+
+from roundup.backends import anydbm
+from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class
+
+class SchemaTestCase(unittest.TestCase):
+ def setUp(self):
+ class Database(anydbm.Database):
+ pass
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ self.db = Database('_test_dir', 'test')
+ self.db.clear()
+
+ def tearDown(self):
+ self.db.close()
+ shutil.rmtree('_test_dir')
+
+ def testA_Status(self):
+ status = Class(self.db, "status", name=String())
+ self.assert_(status, 'no class object generated')
+ status.setkey("name")
+ val = status.create(name="unread")
+ self.assertEqual(val, '1', 'expecting "1"')
+ val = status.create(name="in-progress")
+ self.assertEqual(val, '2', 'expecting "2"')
+ val = status.create(name="testing")
+ self.assertEqual(val, '3', 'expecting "3"')
+ val = status.create(name="resolved")
+ self.assertEqual(val, '4', 'expecting "4"')
+ val = status.count()
+ self.assertEqual(val, 4, 'expecting 4')
+ val = status.list()
+ self.assertEqual(val, ['1', '2', '3', '4'], 'blah')
+ val = status.lookup("in-progress")
+ self.assertEqual(val, '2', 'expecting "2"')
+ status.retire('3')
+ val = status.list()
+ self.assertEqual(val, ['1', '2', '4'], 'blah')
+
+ def testB_Issue(self):
+ issue = Class(self.db, "issue", title=String(), status=Link("status"))
+ self.assert_(issue, 'no class object returned')
+
+ def testC_User(self):
+ user = Class(self.db, "user", username=String(), password=String())
+ self.assert_(user, 'no class object returned')
+ user.setkey("username")
+
+
+def suite():
+ return unittest.makeSuite(SchemaTestCase, 'test')
+
+
+#
+# $Log: not supported by cvs2svn $
+# Revision 1.3 2001/07/25 04:34:31 richard
+# Added id and log to tests files...
+#
+#
diff --git a/tests/README.TXT b/tests/README.TXT
--- a/tests/README.TXT
+++ /dev/null
@@ -1,23 +0,0 @@
-$Id: README.TXT,v 1.2 2001-07-25 04:34:31 richard Exp $
-
-Structre of the tests:
-
- 1 Test date classes
- 1.1 Date
- 1.2 Interval
- 2 Set up schema
- 3 Open with specific backend
- 3.1 anydbm
- 3.2 bsddb
- 4 Create database base set (stati, priority, etc)
- 5 Perform some actions
- 6 Perform mail import
- 6.1 text/plain
- 6.2 multipart/mixed (with one text/plain)
- 6.3 text/html
- 6.4 multipart/alternative (with one text/plain)
- 6.5 multipart/alternative (with no text/plain)
-
-
-------
-$Log: not supported by cvs2svn $
diff --git a/tests/__init__.py b/tests/__init__.py
--- a/tests/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# $Id: __init__.py,v 1.3 2001-07-25 04:34:31 richard Exp $
-
-import unittest
-
-import test_dates, test_schema, test_db
-
-def go():
- suite = unittest.TestSuite((
- test_dates.suite(),
- test_schema.suite(),
- test_db.suite(),
- ))
- runner = unittest.TextTestRunner()
- runner.run(suite)
-
-#
-# $Log: not supported by cvs2svn $
-#
diff --git a/tests/test_dates.py b/tests/test_dates.py
--- a/tests/test_dates.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# $Id: test_dates.py,v 1.2 2001-07-25 04:34:31 richard Exp $
-
-import unittest, time
-
-from roundup.date import Date, Interval
-
-class DateTestCase(unittest.TestCase):
- def testDateInterval(self):
- date = Date("2000-06-26.00:34:02 + 2d")
- self.assertEqual(str(date), '2000-06-28.00:34:02')
- date = Date("2000-02-27 + 2d")
- self.assertEqual(str(date), '2000-02-29.00:00:00')
- date = Date("2001-02-27 + 2d")
- self.assertEqual(str(date), '2001-03-01.00:00:00')
-
- def testDate(self):
- date = Date("2000-04-17")
- self.assertEqual(str(date), '2000-04-17.00:00:00')
- date = Date("01-25")
- y, m, d, x, x, x, x, x, x = time.gmtime()
- self.assertEqual(str(date), '%s-01-25.00:00:00'%y)
- date = Date("2000-04-17.03:45")
- self.assertEqual(str(date), '2000-04-17.03:45:00')
- date = Date("08-13.22:13")
- self.assertEqual(str(date), '%s-08-13.22:13:00'%y)
- date = Date("11-07.09:32:43")
- self.assertEqual(str(date), '%s-11-07.09:32:43'%y)
- date = Date("14:25")
- self.assertEqual(str(date), '%s-%02d-%02d.14:25:00'%(y, m, d))
- date = Date("8:47:11")
- self.assertEqual(str(date), '%s-%02d-%02d.08:47:11'%(y, m, d))
-
- def testOffset(self):
- date = Date("2000-04-17", -5)
- self.assertEqual(str(date), '2000-04-17.00:00:00')
- date = Date("01-25", -5)
- y, m, d, x, x, x, x, x, x = time.gmtime()
- self.assertEqual(str(date), '%s-01-25.00:00:00'%y)
- date = Date("2000-04-17.03:45", -5)
- self.assertEqual(str(date), '2000-04-17.08:45:00')
- date = Date("08-13.22:13", -5)
- self.assertEqual(str(date), '%s-08-14.03:13:00'%y)
- date = Date("11-07.09:32:43", -5)
- self.assertEqual(str(date), '%s-11-07.14:32:43'%y)
- date = Date("14:25", -5)
- self.assertEqual(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
- date = Date("8:47:11", -5)
- self.assertEqual(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
-
- def testInterval(self):
- pass
-
-def suite():
- return unittest.makeSuite(DateTestCase, 'test')
-
-
-#
-# $Log: not supported by cvs2svn $
-#
diff --git a/tests/test_db.py b/tests/test_db.py
--- a/tests/test_db.py
+++ /dev/null
@@ -1,169 +0,0 @@
-# $Id: test_db.py,v 1.7 2001-07-27 06:26:43 richard Exp $
-
-import unittest, os, shutil
-
-from roundup.backends import anydbm
-from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class, \
- DatabaseError
-
-def setupSchema(db, create):
- status = Class(db, "status", name=String())
- status.setkey("name")
- if create:
- status.create(name="unread")
- status.create(name="in-progress")
- status.create(name="testing")
- status.create(name="resolved")
- Class(db, "user", username=String(), password=String())
- Class(db, "issue", title=String(), status=Link("status"),
- nosy=Multilink("user"))
-
-class DBTestCase(unittest.TestCase):
- def setUp(self):
- class Database(anydbm.Database):
- pass
- # remove previous test, ignore errors
- if os.path.exists('_test_dir'):
- shutil.rmtree('_test_dir')
- os.mkdir('_test_dir')
- self.db = Database('_test_dir', 'test')
- setupSchema(self.db, 1)
-
- def tearDown(self):
- self.db.close()
- shutil.rmtree('_test_dir')
-
- def testChanges(self):
- self.db.issue.create(title="spam", status='1')
- self.db.issue.create(title="eggs", status='2')
- self.db.issue.create(title="ham", status='4')
- self.db.issue.create(title="arguments", status='2')
- self.db.issue.create(title="abuse", status='1')
- self.db.issue.addprop(fixer=Link("user"))
- props = self.db.issue.getprops()
- keys = props.keys()
- keys.sort()
- self.assertEqual(keys, ['fixer', 'nosy', 'status', 'title'])
- self.db.issue.set('5', status='2')
- self.db.issue.get('5', "status")
- self.db.status.get('2', "name")
- self.db.issue.get('5', "title")
- self.db.issue.find(status = self.db.status.lookup("in-progress"))
- self.db.issue.history('5')
- self.db.status.history('1')
- self.db.status.history('2')
-
- def testExceptions(self):
- # this tests the exceptions that should be raised
- ar = self.assertRaises
-
- #
- # class create
- #
- # string property
- ar(TypeError, self.db.status.create, name=1)
- # invalid property name
- ar(KeyError, self.db.status.create, foo='foo')
- # key name clash
- ar(ValueError, self.db.status.create, name='unread')
- # invalid link index
- ar(IndexError, self.db.issue.create, title='foo', status='bar')
- # invalid link value
- ar(ValueError, self.db.issue.create, title='foo', status=1)
- # invalid multilink type
- ar(TypeError, self.db.issue.create, title='foo', status='1',
- nosy='hello')
- # invalid multilink index type
- ar(ValueError, self.db.issue.create, title='foo', status='1',
- nosy=[1])
- # invalid multilink index
- ar(IndexError, self.db.issue.create, title='foo', status='1',
- nosy=['10'])
-
- #
- # class get
- #
- # invalid node id
- ar(IndexError, self.db.status.get, '10', 'name')
- # invalid property name
- ar(KeyError, self.db.status.get, '2', 'foo')
-
- #
- # class set
- #
- # invalid node id
- ar(IndexError, self.db.issue.set, '1', name='foo')
- # invalid property name
- ar(KeyError, self.db.status.set, '1', foo='foo')
- # string property
- ar(TypeError, self.db.status.set, '1', name=1)
- # key name clash
- ar(ValueError, self.db.status.set, '2', name='unread')
- # set up a valid issue for me to work on
- self.db.issue.create(title="spam", status='1')
- # invalid link index
- ar(IndexError, self.db.issue.set, '1', title='foo', status='bar')
- # invalid link value
- ar(ValueError, self.db.issue.set, '1', title='foo', status=1)
- # invalid multilink type
- ar(TypeError, self.db.issue.set, '1', title='foo', status='1',
- nosy='hello')
- # invalid multilink index type
- ar(ValueError, self.db.issue.set, '1', title='foo', status='1',
- nosy=[1])
- # invalid multilink index
- ar(IndexError, self.db.issue.set, '1', title='foo', status='1',
- nosy=['10'])
-
- def testRetire(self):
- ''' test retiring a node
- '''
- pass
-
-
-class ReadOnlyDBTestCase(unittest.TestCase):
- def setUp(self):
- class Database(anydbm.Database):
- pass
- # remove previous test, ignore errors
- if os.path.exists('_test_dir'):
- shutil.rmtree('_test_dir')
- os.mkdir('_test_dir')
- db = Database('_test_dir', 'test')
- setupSchema(db, 1)
- db.close()
- self.db = Database('_test_dir')
- setupSchema(self.db, 0)
-
- def tearDown(self):
- self.db.close()
- shutil.rmtree('_test_dir')
-
- def testExceptions(self):
- # this tests the exceptions that should be raised
- ar = self.assertRaises
-
- # this tests the exceptions that should be raised
- ar(DatabaseError, self.db.status.create, name="foo")
- ar(DatabaseError, self.db.status.set, '1', name="foo")
- ar(DatabaseError, self.db.status.retire, '1')
-
-
-def suite():
- db = unittest.makeSuite(DBTestCase, 'test')
- readonlydb = unittest.makeSuite(ReadOnlyDBTestCase, 'test')
- return unittest.TestSuite((db, readonlydb))
-
-
-#
-# $Log: not supported by cvs2svn $
-# Revision 1.6 2001/07/27 06:23:59 richard
-# consistency
-#
-# Revision 1.5 2001/07/27 06:23:09 richard
-# Added some new hyperdb tests to make sure we raise the right exceptions.
-#
-# Revision 1.4 2001/07/25 04:34:31 richard
-# Added id and log to tests files...
-#
-#
diff --git a/tests/test_schema.py b/tests/test_schema.py
--- a/tests/test_schema.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# $Id: test_schema.py,v 1.3 2001-07-25 04:34:31 richard Exp $
-
-import unittest, os, shutil
-
-from roundup.backends import anydbm
-from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class
-
-class SchemaTestCase(unittest.TestCase):
- def setUp(self):
- class Database(anydbm.Database):
- pass
- # remove previous test, ignore errors
- if os.path.exists('_test_dir'):
- shutil.rmtree('_test_dir')
- os.mkdir('_test_dir')
- self.db = Database('_test_dir', 'test')
- self.db.clear()
-
- def tearDown(self):
- self.db.close()
- shutil.rmtree('_test_dir')
-
- def testA_Status(self):
- status = Class(self.db, "status", name=String())
- self.assert_(status, 'no class object generated')
- status.setkey("name")
- val = status.create(name="unread")
- self.assertEqual(val, '1', 'expecting "1"')
- val = status.create(name="in-progress")
- self.assertEqual(val, '2', 'expecting "2"')
- val = status.create(name="testing")
- self.assertEqual(val, '3', 'expecting "3"')
- val = status.create(name="resolved")
- self.assertEqual(val, '4', 'expecting "4"')
- val = status.count()
- self.assertEqual(val, 4, 'expecting 4')
- val = status.list()
- self.assertEqual(val, ['1', '2', '3', '4'], 'blah')
- val = status.lookup("in-progress")
- self.assertEqual(val, '2', 'expecting "2"')
- status.retire('3')
- val = status.list()
- self.assertEqual(val, ['1', '2', '4'], 'blah')
-
- def testB_Issue(self):
- issue = Class(self.db, "issue", title=String(), status=Link("status"))
- self.assert_(issue, 'no class object returned')
-
- def testC_User(self):
- user = Class(self.db, "user", username=String(), password=String())
- self.assert_(user, 'no class object returned')
- user.setkey("username")
-
-
-def suite():
- return unittest.makeSuite(SchemaTestCase, 'test')
-
-
-#
-# $Log: not supported by cvs2svn $
-#