author | fabien@tzone.org |
Tue, 30 Dec 2008 23:16:05 -0500 | |
changeset 66 | a0aa025ee6a2 |
parent 65 | b975a3d7606a |
child 70 | 1798859f7f6c |
permissions | -rw-r--r-- |
66 | 1 |
import testconfig |
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
2 |
import unittest |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
3 |
import my_db |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
4 |
import pgdb |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
5 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
6 |
class TestMyDbConnexion(unittest.TestCase): |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
7 |
def setUp(self): |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
8 |
" Setup a test-db environment." |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
9 |
self.db = my_db.connect(testconfig.CONFIG, "test") |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
10 |
self.prefs = { 'keywords_box' : 10, |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
11 |
'keywords_sort' : 'count', |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
12 |
'keywords_reverse': True, |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
13 |
'fullname': 'Test User', |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
14 |
'default_view': 1 } |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
15 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
16 |
def tearDown(self): |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
17 |
" Tear down the test-db environment" |
66 | 18 |
self.db.delete_user(self.db.userid) |
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
19 |
pass |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
20 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
21 |
def testConnect(self): |
66 | 22 |
self.assertNotEqual(self.db, None) |
23 |
self.assertNotEqual(self.db.userid, -1) |
|
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
24 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
25 |
def testGetPreferences(self): |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
26 |
prefs = self.db.get_preferences() |
66 | 27 |
keys = prefs.keys() |
28 |
keys.sort() |
|
29 |
expKeys = self.prefs.keys() |
|
30 |
expKeys.sort() |
|
31 |
self.assertEqual(expKeys, keys) |
|
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
32 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
33 |
def testSetPreferences(self): |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
34 |
self.db.set_preferences(self.prefs) |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
35 |
prefs = self.db.get_preferences() |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
36 |
self.assertEqual(prefs, self.prefs) |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
37 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
38 |
if __name__ == '__main__': |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
39 |
unittest.main() |