| author | fabien@tzone.org | 
| Wed, 31 Dec 2008 00:00:09 -0500 | |
| changeset 68 | c1f1491f098c | 
| parent 65 | b975a3d7606a | 
| child 66 | a0aa025ee6a2 | 
| permissions | -rw-r--r-- | 
| 
65
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
1  | 
if __name__ == '__main__':  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
2  | 
import sys  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
3  | 
sys.path.insert(0, "../../lib")  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
4  | 
|
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
5  | 
import unittest  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
6  | 
import my_db  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
7  | 
import testconfig  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
8  | 
import pgdb  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
10  | 
class TestMyDbConnexion(unittest.TestCase):  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
11  | 
def setUp(self):  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
12  | 
" Setup a test-db environment."  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
13  | 
self.db = my_db.connect(testconfig.CONFIG, "test")  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
14  | 
        self.prefs = { 'keywords_box' : 10,
 | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
15  | 
'keywords_sort' : 'count',  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
16  | 
'keywords_reverse': True,  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
17  | 
'fullname': 'Test User',  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
18  | 
'default_view': 1 }  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
19  | 
|
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
20  | 
def tearDown(self):  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
21  | 
" Tear down the test-db environment"  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
22  | 
        self.db.delete_user('test')
 | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
23  | 
pass  | 
| 
 
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 testConnect(self):  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
26  | 
self.assertNotEqual(db, None)  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
27  | 
self.assertNotEqual(db.userid, -1)  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
28  | 
|
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
29  | 
def testGetPreferences(self):  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
30  | 
prefs = self.db.get_preferences()  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
31  | 
self.assertEqual(prefs, self.prefs)  | 
| 
 
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  | 
|
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
39  | 
if __name__ == '__main__':  | 
| 
 
b975a3d7606a
Partial submission, to include tests.
 
Fabien Ninoles <fabien@tzone.org> 
parents:  
diff
changeset
 | 
40  | 
unittest.main()  |