-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
38 lines (30 loc) · 963 Bytes
/
tests.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
import unittest
import parser
import settings
import db
DB = settings.DB(True)
class ParseTest(unittest.TestCase):
def test_parse(self):
db.drop_table(DB)
db.create_index(DB)
parser.parse("test", True)
prod = list(DB.products.find())
self.assertEqual(len(prod), 1)
self.assertEqual(prod[0]['uid'], '400000022199')
# class ParseCSVTest(unittest.TestCase):
# def test_parse(self):
# db.drop_table(DB)
# db.create_index(DB)
# parser.parse("csv", True)
# prod = list(DB.products.find())
# self.assertEqual(len(prod), 7051)
# class ParseXMLTest(unittest.TestCase):
# def test_parse(self):
# db.drop_table(DB)
# db.create_index(DB)
# parser.parse("xml", True)
# prod = list(DB.products.find())
# self.assertEqual(len(prod), 355)
# Launch tests: python -m unittest tests.py
if __name__ == '__main__':
unittest.main()