Mercurial > p > roundup > code
comparison test/test_init.py @ 205:da2e5d340e14
Added tests for instance initialisation
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 05 Aug 2001 07:45:27 +0000 |
| parents | 23bc73d13edf |
| children | d45384bc6420 |
comparison
equal
deleted
inserted
replaced
| 204:c1461733cbf9 | 205:da2e5d340e14 |
|---|---|
| 1 # $Id: test_init.py,v 1.1 2001-08-05 07:07:58 richard Exp $ | 1 # $Id: test_init.py,v 1.2 2001-08-05 07:45:27 richard Exp $ |
| 2 | 2 |
| 3 import unittest, os, shutil, errno, imp, sys | 3 import unittest, os, shutil, errno, imp, sys |
| 4 | 4 |
| 5 from roundup.init import init | 5 from roundup.init import init |
| 6 | 6 |
| 7 class MyTestCase(unittest.TestCase): | 7 class MyTestCase(unittest.TestCase): |
| 8 count = 0 | |
| 9 def setUp(self): | |
| 10 MyTestCase.count = MyTestCase.count + 1 | |
| 11 self.dirname = '_test_%s'%self.count | |
| 12 try: | |
| 13 shutil.rmtree(self.dirname) | |
| 14 except OSError, error: | |
| 15 if error.errno != errno.ENOENT: raise | |
| 16 | |
| 8 def tearDown(self): | 17 def tearDown(self): |
| 9 try: | 18 try: |
| 10 shutil.rmtree('_test_dir') | 19 shutil.rmtree(self.dirname) |
| 11 except OSError, error: | 20 except OSError, error: |
| 12 if error.errno == errno.ENOENT: raise | 21 if error.errno != errno.ENOENT: raise |
| 13 | 22 |
| 14 class ClassicTestCase(MyTestCase): | 23 class ClassicTestCase(MyTestCase): |
| 15 backend = 'anydbm' | 24 backend = 'anydbm' |
| 16 def testCreation(self): | 25 def testCreation(self): |
| 17 ae = self.assertEqual | 26 ae = self.assertEqual |
| 18 | 27 |
| 19 # create the instance | 28 # create the instance |
| 20 init('_test_dir', 'classic', self.backend, 'sekrit') | 29 init(self.dirname, 'classic', self.backend, 'sekrit') |
| 21 | 30 |
| 22 # check we can load the package | 31 # check we can load the package |
| 23 instance = imp.load_package('_test_dir', '_test_dir') | 32 instance = imp.load_package(self.dirname, self.dirname) |
| 24 | 33 |
| 25 # and open the database | 34 # and open the database |
| 26 db = instance.open() | 35 db = instance.open() |
| 27 | 36 |
| 28 # check the basics of the schema and initial data set | 37 # check the basics of the schema and initial data set |
| 45 backend = 'anydbm' | 54 backend = 'anydbm' |
| 46 def testCreation(self): | 55 def testCreation(self): |
| 47 ae = self.assertEqual | 56 ae = self.assertEqual |
| 48 | 57 |
| 49 # create the instance | 58 # create the instance |
| 50 init('_test_dir', 'extended', self.backend, 'sekrit') | 59 init(self.dirname, 'extended', self.backend, 'sekrit') |
| 51 | 60 |
| 52 # check we can load the package | 61 # check we can load the package |
| 53 del sys.modules['_test_dir'] | 62 instance = imp.load_package(self.dirname, self.dirname) |
| 54 instance = imp.load_package('_test_dir', '_test_dir') | |
| 55 | 63 |
| 56 # and open the database | 64 # and open the database |
| 57 db = instance.open() | 65 db = instance.open() |
| 58 | 66 |
| 59 # check the basics of the schema and initial data set | 67 # check the basics of the schema and initial data set |
| 60 l = db.priority.list() | 68 l = db.priority.list() |
| 61 ae(l, ['1', '2', '3', '4', '5']) | 69 ae(l, ['1', '2', '3', '4']) |
| 62 l = db.status.list() | 70 l = db.status.list() |
| 63 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8']) | 71 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8']) |
| 64 l = db.keyword.list() | 72 l = db.keyword.list() |
| 65 ae(l, []) | 73 ae(l, []) |
| 66 l = db.user.list() | 74 l = db.user.list() |
| 109 | 117 |
| 110 return unittest.TestSuite(l) | 118 return unittest.TestSuite(l) |
| 111 | 119 |
| 112 # | 120 # |
| 113 # $Log: not supported by cvs2svn $ | 121 # $Log: not supported by cvs2svn $ |
| 122 # Revision 1.1 2001/08/05 07:07:58 richard | |
| 123 # added tests for roundup.init - but they're disabled until I can figure _if_ | |
| 124 # we can run them (import problems). | |
| 125 # | |
| 114 # | 126 # |
| 115 # | 127 # |
| 116 # vim: set filetype=python ts=4 sw=4 et si | 128 # vim: set filetype=python ts=4 sw=4 et si |
