Newer
Older
#!/usr/bin/env python
from unittest import TestCase
from doc.analysis.generaterobotdata import GenerateRobotData
from json import load, dump
from deepdiff import DeepDiff
from os.path import dirname, exists
from os import listdir, remove, makedirs
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
class TestCSRegistration(TestCase):
@classmethod
def setUpClass(cls):
TestCSRegistration.folder_test_suites = dirname(dirname(dirname(__file__)))
folder_results = f'{TestCSRegistration.folder_test_suites}/doc/results'
# Check that the folder '/results' exists and if not, create it
if not exists(folder_results):
makedirs(folder_results)
else:
# Delete the /results folder
[remove(f'{folder_results}/{x}') for x in listdir(folder_results) if x.startswith('out')]
def setUp(self) -> None:
self.folder_test_suites = dirname(dirname(dirname(__file__)))
def common_function(self, robot_file, expected_value, difference_file):
data = GenerateRobotData(robot_file=robot_file,
execdir=self.folder_test_suites)
data.parse_robot()
obtained_response = data.get_info()
with open(expected_value, 'r') as file:
expected_response = load(file)
result = DeepDiff(t1=obtained_response, t2=expected_response, ignore_order=True)
if len(result) != 0:
# There are some differences
with open(difference_file, 'w') as fp:
dump(obj=obtained_response, indent=2, fp=fp)
assert False, f'They are some difference between the expected and obtained dictionaries: \n {result}'
def test_033_01_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_01_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_01_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_01_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
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
warnings.warn(UserWarning("WARNING, (033_01_01) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_01_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_01_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_01_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_01_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_01_02) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_01_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_01_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_01_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_01_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_01_03) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_02(self):
self.fail("(033_02) Test Suite with Test Template, not yet implemented")
def test_033_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_03) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_04) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_05(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_05.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_05.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_05.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_05) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_06(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_06.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_06.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_06.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_033_07(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_07.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_07.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_07.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
warnings.warn(UserWarning("WARNING, (033_07) The doc generate the info based on the retrieve operation and not to the create operation"))
def test_033_08(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_08.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_08.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_08.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_033_09(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/CreateContextSourceRegistration/033_09.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/033_09.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_033_09.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_033_10(self):
self.fail("(033_10) Test Suite with Test Template, not yet implemented")
def test_028_02(self):
self.fail("(028_02) Test Suite with Test Template, not yet implemented")
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def test_035_01(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_01.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/035_01.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_035_01.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_035_02(self):
self.fail("(035_02) Test Suite with Test Template, not yet implemented")
def test_035_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/035_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_035_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_037_01(self):
self.fail("(037_01) Test Suite with Test Template, not yet implemented")
def test_037_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/037_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_037_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_037_03(self):
self.fail("(037_03) Test Suite with Test Template, not yet implemented")
def test_037_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/037_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_037_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_037_05(self):
self.fail("(037_05) Test Suite with Test Template, not yet implemented")
def test_037_06(self):
self.fail("(037_06) Test Suite with Test Template, not yet implemented")
def test_037_07(self):
self.fail("(037_07) Test Suite with Test Template, not yet implemented")
def test_037_08(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/QueryContextSourceRegistrations/037_08.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/037_08.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_037_08.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_037_09(self):
self.fail("(037_09) Test Suite with Test Template, not yet implemented")
def test_037_10(self):
self.fail("(037_10) Test Suite with Test Template, not yet implemented")
def test_037_11(self):
self.fail("(037_11) Test Suite with Test Template, not yet implemented")
def test_036_01(self):
self.fail("(037_11) Test Suite with Test Template, not yet implemented")
def test_036_02(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_02.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/036_02.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_036_02.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_036_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/036_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_036_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_036_04(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_04.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/036_04.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_036_04.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)
def test_036_05(self):
self.fail("(036_05) Test Suite with Test Template, not yet implemented")
def test_034_01(self):
self.fail("(034_01) Test Suite with Test Template, not yet implemented")
def test_034_02(self):
self.fail("(034_02) Test Suite with Test Template, not yet implemented")
def test_034_04(self):
self.fail("(034_04) Test Suite with Test Template, not yet implemented")
def test_034_03(self):
robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot'
expected_value = f'{self.folder_test_suites}/doc/files/ContextSource/Registration/034_03.json'
difference_file = f'{self.folder_test_suites}/doc/results/out_034_03.json'
self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file)