forked from Nandaka/PixivUtil2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.PixivDBManager.py
43 lines (36 loc) · 1.48 KB
/
test.PixivDBManager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/c/Python27/python.exe
# -*- coding: UTF-8 -*-
from PixivDBManager import PixivDBManager
from PixivModel import PixivListItem
from PixivConfig import PixivConfig
import unittest
LIST_SIZE = 4
config = PixivConfig()
config.loadConfig()
class TestPixivDBManager(unittest.TestCase):
def testImportListTxt(self):
DB = PixivDBManager(target = "test.db.sqlite")
DB.createDatabase()
l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
result = DB.importList(l)
self.assertEqual(result, 0)
def testSelectMembersByLastDownloadDate(self):
DB = PixivDBManager(target = "test.db.sqlite")
DB.createDatabase()
l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
result = DB.selectMembersByLastDownloadDate(7)
self.assertEqual(len(result), LIST_SIZE)
for item in result:
print item.memberId, item.path
def testSelectAllMember(self):
DB = PixivDBManager(target = "test.db.sqlite")
DB.createDatabase()
l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
result = DB.selectAllMember()
self.assertEqual(len(result), LIST_SIZE)
for item in result:
print item.memberId, item.path
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestPixivDBManager)
unittest.TextTestRunner(verbosity=5).run(suite)
print "================================================================"