/
test_breadcrumb.py
80 lines (75 loc) · 3.97 KB
/
test_breadcrumb.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
from ..resources import NemoResource
from mock import patch
from flask_nemo.plugins.default import Breadcrumb
class TestBreadcrumb(NemoResource):
""" Test Breadcrumb default Plugins
"""
def test_make_passage_breadcrumb(self):
""" passage breadcrumb should include all components up to passage and passage not linked
"""
with patch("requests.get", return_value=self.getCapabilities):
make_breadcrumbs = Breadcrumb().render
bc = make_breadcrumbs(
textgroups=self.nemo.get_textgroups(),
version=self.nemo.get_text("latinLit", "phi1294", "phi002", "perseus-lat2"),
lang="eng",
url={
"collection": "latinLit",
"textgroup": "phi1294",
"work": "phi002",
"version": "perseus-lat2",
"passage_identifier": "1.1"
})["breadcrumbs"]
self.assertEqual(bc,[
{'link': '.r_collection', 'title': 'latinLit', 'args': {'collection': 'latinLit'}},
{'link': '.r_texts', 'title': 'Martial', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit'}},
{'link': '.r_version', 'title': 'Epigrammata Label', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit', 'work':'phi002','version':'perseus-lat2'}},
{'link': None, 'title': '1.1', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit', 'work':'phi002','version':'perseus-lat2', 'passage_identifier':"1.1"}}
])
def test_make_version_breadcrumb(self):
""" version breadcrumb should include all components up to version and version not linked
"""
with patch("requests.get", return_value=self.getCapabilities):
make_breadcrumbs = Breadcrumb().render
bc = make_breadcrumbs(
textgroups=self.nemo.get_textgroups(),
version = self.nemo.get_text("latinLit","phi1294","phi002","perseus-lat2"),
lang="eng",
url={
"collection": "latinLit",
"textgroup": "phi1294",
"work": "phi002",
"version": "perseus-lat2"
})["breadcrumbs"]
self.assertEqual(bc,[
{'link': '.r_collection', 'title': 'latinLit', 'args': {'collection': 'latinLit'}},
{'link': '.r_texts', 'title': 'Martial', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit'}},
{'link': None, 'title': 'Epigrammata Label', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit', 'work':'phi002','version':'perseus-lat2'}}
])
def test_make_textgroup_breadcrumb(self):
""" textgroup breadcrumb should include all components up to textgroup and textgroup not linked
"""
with patch("requests.get", return_value=self.getCapabilities):
make_breadcrumbs = Breadcrumb().render
bc = make_breadcrumbs(
textgroups=self.nemo.get_textgroups(),
lang="eng",
url={
"collection": "latinLit",
"textgroup": "phi1294",
})["breadcrumbs"]
self.assertEqual(bc, [
{'link': '.r_collection', 'title': 'latinLit', 'args': {'collection': 'latinLit'}},
{'link': None, 'title': 'Martial', 'args': {'textgroup': 'phi1294', 'collection': 'latinLit'}}
])
def test_make_collection_breadcrumb(self):
""" collection breadcrumb should include only collection not linked
"""
with patch("requests.get", return_value=self.getCapabilities):
make_breadcrumbs = Breadcrumb().render
bc = make_breadcrumbs(
lang="eng",
url={"collection": "latinLit"})["breadcrumbs"]
self.assertEqual(bc, [
{'link': None, 'title': 'latinLit', 'args': {'collection': 'latinLit'}}
])