author | Fabien Niñoles <fabien@tzone.org> |
Wed, 07 Jan 2009 17:26:18 -0500 | |
changeset 77 | 52b13b0616b8 |
parent 72 | 34fcc8b2c1f5 |
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 |
71 | 3 |
import keywords |
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
4 |
import my_db |
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
5 |
|
72
34fcc8b2c1f5
Only add unique keywords and remove utils.py, which I'm not sure about
fabien@tzone.org
parents:
71
diff
changeset
|
6 |
class TestKeywordsWithDB(unittest.TestCase): |
70 | 7 |
def setUp(self): |
8 |
" Setup a test-db environment." |
|
9 |
self.db = my_db.connect(testconfig.CONFIG, "test") |
|
10 |
||
11 |
def tearDown(self): |
|
12 |
" Tear down the test-db environment" |
|
13 |
self.db.delete_user(self.db.userid) |
|
14 |
||
71 | 15 |
def _get_all_kw(self): |
16 |
res = self.db.get_all_keywords()[1:] |
|
17 |
res = map(lambda x: x[1], res) |
|
18 |
res.sort() |
|
19 |
return res |
|
20 |
def testAddUniqueKeywords(self): |
|
21 |
kws1 = ['a1','a2', 'a3'] |
|
22 |
kws2 = ['a1', 'b1','b2', 'b3'] |
|
23 |
all_kw = list(set(kws1+kws2)) |
|
24 |
all_kw.sort() |
|
25 |
kws1.sort() |
|
26 |
kws2.sort() |
|
27 |
keywords.add_unique_keywords(self.db, kws1) |
|
28 |
self.assertEqual(kws1, self._get_all_kw()) |
|
29 |
keywords.add_unique_keywords(self.db, kws2) |
|
30 |
self.assertEqual(all_kw, self._get_all_kw()) |
|
65
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
31 |
|
b975a3d7606a
Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents:
diff
changeset
|
32 |
if __name__ == '__main__': |
71 | 33 |
unittest.main() |