-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_jsonld.py
134 lines (107 loc) · 4.85 KB
/
test_jsonld.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"""
Tests to test results from comparejsonld.py match those from comparejson.py
"""
import unittest
from comparejsonld import CompareJSONLD
from compareshape import CompareShape
from shape import Shape
class JSONLDCase(unittest.TestCase):
"""
Testcases to test results from comparejsonld.py match those from comparejson.py
"""
@classmethod
def setUpClass(cls) -> None:
language: str = "en"
schema: str = "E236"
entity: str = "Q1728820"
shape: Shape = Shape(schema, language)
cls.comparison: CompareShape = CompareShape(shape.get_schema_shape(), entity, language)
cls.comparison2: CompareJSONLD = CompareJSONLD(shape.get_json_ld(), entity, language)
def test_compare_property_names(self) -> None:
"""
tests to see if the names of the properties are the same in both cases
:return: Nothing
"""
for prop in self.comparison.get_properties():
self.assertEqual(self.comparison.get_properties()[prop]["name"],
self.comparison2.get_properties()[prop]["name"])
def test_compare_property_necessity(self) -> None:
"""
tests to see if the necessity of the properties are the same in both cases
:return: Nothing
"""
for prop in self.comparison.get_properties():
self.assertEqual(self.comparison.get_properties()[prop]["necessity"],
self.comparison2.get_properties()[prop]["necessity"])
def test_compare_property_response(self) -> None:
"""
tests to see if the response of the properties are the same in both cases
:return: Nothing
"""
for prop in self.comparison.get_properties():
if "response" in self.comparison2.get_properties()[prop]:
self.assertEqual(self.comparison.get_properties()[prop]["response"],
self.comparison2.get_properties()[prop]["response"])
def test_compare_property_p21(self) -> None:
"""
tests to see that the P21 property is assessed the same in both cases
:return: Nothing
"""
self.assertEqual(self.comparison.get_properties()["P21"],
self.comparison2.get_properties()["P21"])
def test_compare_property_p734(self) -> None:
"""
tests to see that the P734 property is assessed the same in both cases
:return: Nothing
"""
self.assertEqual(self.comparison.get_properties()["P734"],
self.comparison2.get_properties()["P734"])
def test_compare_properties(self) -> None:
"""
tests to see that the properties are assessed the same in both cases
:return: Nothing
"""
self.assertEqual(self.comparison.get_properties(),
self.comparison2.get_properties())
def test_compare_statements(self) -> None:
"""
tests to see that the statements are assessed the same in both cases
:return: Nothing
"""
self.assertEqual(self.comparison.get_statements(),
self.comparison2.get_statements())
def test_compare_statement_property(self) -> None:
"""
tests to see if the names of the properties are the same in both cases
:return: Nothing
"""
for statement in self.comparison.get_statements():
self.assertEqual(self.comparison.get_statements()[statement]["property"],
self.comparison2.get_statements()[statement]["property"])
def test_compare_statement_necessity(self) -> None:
"""
tests to see if the necessity of the properties are the same in both cases
:return: Nothing
"""
for statement in self.comparison.get_statements():
if "necessity" in self.comparison2.get_statements()[statement]:
self.assertEqual(self.comparison.get_statements()[statement]["necessity"],
self.comparison2.get_statements()[statement]["necessity"])
def test_compare_statement_response(self) -> None:
"""
tests to see if the response of the properties are the same in both cases
:return: Nothing
"""
for statement in self.comparison.get_statements():
if "response" in self.comparison2.get_statements()[statement]:
self.assertEqual(self.comparison.get_statements()[statement]["response"],
self.comparison2.get_statements()[statement]["response"])
def test_compare_general(self) -> None:
"""
tests to see that general is assessed the same in both cases
:return: Nothing
"""
self.assertEqual(self.comparison.get_general(),
self.comparison2.get_general())
if __name__ == '__main__':
unittest.main()