-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-server.py
60 lines (35 loc) · 1.3 KB
/
test-server.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
import unittest
import collections
from server import get_summary
class ServerTest(unittest.TestCase):
def test_get_summary(self):
text = """# Title 1
## Subtitle 11
### Article 11-1
Habeas corpus 11-1.
Habeas rosam 11-1.
# Title 2
## Subtitle 21
### Subsubtitle 211
#### Article 211-1
Habeas corpus 211-1.
Habeas rosam 211-1.
#### Article 211-2
Habeas corpus 211-2.
Habeas rosam 211-1.
"""
summary = collections.OrderedDict()
summary['Title 1'] = collections.OrderedDict()
summary['Title 1']['Subtitle 11'] = collections.OrderedDict({'Article 11-1': None})
summary['Title 2'] = collections.OrderedDict()
summary['Title 2']['Subtitle 21'] = collections.OrderedDict()
summary['Title 2']['Subtitle 21']['Subsubtitle 211'] = collections.OrderedDict({'Article 211-1': None})
summary['Title 2']['Subtitle 21']['Subsubtitle 211']['Article 211-2'] = None
articles = collections.OrderedDict()
articles['11-1'] = ['Title 1', 'Subtitle 11']
articles['211-1'] = ['Title 2', 'Subtitle 21', 'Subsubtitle 211']
articles['211-2'] = ['Title 2', 'Subtitle 21', 'Subsubtitle 211']
self.assertEqual(get_summary(text), (summary, articles))
if __name__ == '__main__':
unittest.main()
# vim: set ts=4 sw=4 sts=4 et: