-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_unit.py
92 lines (82 loc) · 2.64 KB
/
test_unit.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import click, local, os, sqlite3, sqlite_dump, unittest, utils
class TestMLCDB(unittest.TestCase):
mlc_db = utils.MLCDB({
'DB': 'test.sql',
'GLOTTO_TRIPLES': 'data/glottolog_language.ttl',
'MESO_TRIPLES': 'test_data/test.ttl',
'TGN_TRIPLES': 'data/tgn.ttl'
})
def test_list_items(self):
self.assertEqual(
sorted(self.__class__.mlc_db.get_item_list()),
[
'https://ark.lib.uchicago.edu/ark:61001/s1_i1',
'https://ark.lib.uchicago.edu/ark:61001/s1_i2',
'https://ark.lib.uchicago.edu/ark:61001/s1_i3',
'https://ark.lib.uchicago.edu/ark:61001/s2_i1',
'https://ark.lib.uchicago.edu/ark:61001/s2_i2',
'https://ark.lib.uchicago.edu/ark:61001/s2_i3'
]
)
def test_list_series(self):
self.assertEqual(
sorted(self.__class__.mlc_db.get_series_list()),
[
'https://ark.lib.uchicago.edu/ark:61001/s1',
'https://ark.lib.uchicago.edu/ark:61001/s2'
]
)
def test_contributor_browse(self):
self.assertEqual(
self.__class__.mlc_db.get_browse('contributor'),
[
('contributor one', 1),
('contributor two', 1)
]
)
def test_creator_browse(self):
self.assertEqual(
self.__class__.mlc_db.get_browse('creator'),
[
('interviewer one', 1),
('interviewer three', 1),
('interviewer two', 1)
]
)
def test_date_browse(self):
self.assertEqual(
self.__class__.mlc_db.get_browse('date'),
[
('1979/2018', 2)
]
)
def test_decade_browse(self):
self.assertEqual(
self.__class__.mlc_db.get_browse('decade'),
[
('1970s', 2),
('1980s', 2),
('1990s', 2),
('2000s', 2),
('2010s', 2)
]
)
def test_language_browse(self):
self.assertEqual(
self.__class__.mlc_db.get_browse('language'),
[
('English', 2),
('Spanish', 2),
('Yucatec Maya', 2)
]
)
def test_convert_raw_query_to_fts(self):
for s, expected_output in (
('zapo1437', 'zapo1437'),
):
self.assertEqual(
self.__class__.mlc_db.convert_raw_query_to_fts(s),
expected_output
)
if __name__=='__main__':
unittest.main()