Skip to content

Commit 18cf9d6

Browse files
committed
Remove parsing as already parsed
Return objects are already parsed objs, so we don't need to parse them
1 parent d1213a0 commit 18cf9d6

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

test/test_client.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ def test_delete_and_post_aas(self):
145145
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"))
146146
self.aasRepoClient.delete_asset_administration_shell_by_id(
147147
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"))
148-
retrieved_aas_parsed = AASClientTest._parse_object(object=retrieved_aas, encoder=AASToJsonEncoder)
149-
self.aasRepoClient.post_asset_administration_shell(retrieved_aas_parsed)
148+
self.aasRepoClient.post_asset_administration_shell(retrieved_aas)
150149
retrieved_aas_new = self.aasRepoClient.get_asset_administration_shell_by_id(
151150
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"))
152151
self.CHECKER.check_asset_administration_shell_equal(retrieved_aas, retrieved_aas_new)
@@ -165,14 +164,13 @@ def test_delete_and_post_aas_errors(self):
165164

166165
self.aasRepoClient.delete_asset_administration_shell_by_id(
167166
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"))
168-
retrieved_aas_parsed = AASClientTest._parse_object(object=retrieved_aas, encoder=AASToJsonEncoder)
169-
self.aasRepoClient.post_asset_administration_shell(retrieved_aas_parsed)
167+
self.aasRepoClient.post_asset_administration_shell(retrieved_aas)
170168

171169
self._assert_api_exception(
172170
lambda: self.aasRepoClient.post_asset_administration_shell("a"), 422,
173171
"Object 'a' is not of type AssetAdministrationShell!")
174172
self._assert_api_exception(
175-
lambda: self.aasRepoClient.post_asset_administration_shell(retrieved_aas_parsed), 409,
173+
lambda: self.aasRepoClient.post_asset_administration_shell(retrieved_aas), 409,
176174
"AssetAdministrationShell with Identifier "
177175
"https://acplt.org/Test_AssetAdministrationShell already exists!")
178176

@@ -212,15 +210,11 @@ def test_get_delete_and_post_submodel_refs(self):
212210
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"))
213211
# deserialization to model.Modelreference object is not happening
214212
submodel_reference = submodel_references.result[0]
215-
submodel_reference.__class__ = model.ModelReference
216-
submodel_reference_dump = AASToJsonEncoder._reference_to_json(submodel_reference)
217-
submodel_reference_parsed = json.loads(submodel_reference_dump)
218-
submodel_id = submodel_reference_parsed.get('value', None)
219213
self.aasRepoClient.delete_submodel_reference_by_id_aas_repository(
220214
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"),
221-
submodel_identifier=string_to_base64url(submodel_id))
215+
submodel_identifier=string_to_base64url(submodel_reference.get_identifier()))
222216
self.aasRepoClient.post_submodel_reference_aas_repository(
223-
body=submodel_reference_parsed, aas_identifier=string_to_base64url(
217+
body=submodel_reference, aas_identifier=string_to_base64url(
224218
"https://acplt.org/Test_AssetAdministrationShell"))
225219

226220
def test_put_and_get_submodel(self):
@@ -410,10 +404,8 @@ def test_delete_and_post_submodel_element(self):
410404
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"),
411405
submodel_identifier=string_to_base64url(self.example_submodel.id),
412406
id_short_path="ExampleSubmodelCollection")
413-
retrieved_submodel_element_parsed = AASClientTest._parse_object(object=retrieved_submodel_element,
414-
encoder=AASToJsonEncoder)
415407
self.aasRepoClient.post_submodel_element_aas_repository(
416-
body=retrieved_submodel_element_parsed, aas_identifier=string_to_base64url(
408+
body=retrieved_submodel_element, aas_identifier=string_to_base64url(
417409
"https://acplt.org/Test_AssetAdministrationShell"), submodel_identifier=string_to_base64url(
418410
self.example_submodel.id))
419411
retrieved_submodel_element_new = self.aasRepoClient.get_submodel_element_by_path_aas_repository(
@@ -445,10 +437,8 @@ def test_delete_and_post_submodel_element_errors(self):
445437
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"),
446438
submodel_identifier=string_to_base64url(self.example_submodel.id),
447439
id_short_path="ExampleSubmodelCollection")
448-
retrieved_submodel_element_parsed = AASClientTest._parse_object(object=retrieved_submodel_element,
449-
encoder=AASToJsonEncoder)
450440
self.aasRepoClient.post_submodel_element_aas_repository(
451-
body=retrieved_submodel_element_parsed, aas_identifier=string_to_base64url(
441+
body=retrieved_submodel_element, aas_identifier=string_to_base64url(
452442
"https://acplt.org/Test_AssetAdministrationShell"), submodel_identifier=string_to_base64url(
453443
self.example_submodel.id))
454444

@@ -459,7 +449,7 @@ def test_delete_and_post_submodel_element_errors(self):
459449
self.example_submodel.id)), 422, "Object 'a' is not of type SubmodelElement!")
460450
self._assert_api_exception(
461451
lambda: self.aasRepoClient.post_submodel_element_aas_repository(
462-
body=retrieved_submodel_element_parsed, aas_identifier=string_to_base64url(
452+
body=retrieved_submodel_element, aas_identifier=string_to_base64url(
463453
"https://acplt.org/Test_AssetAdministrationShell"), submodel_identifier=string_to_base64url(
464454
self.example_submodel.id)), 409,
465455
"SubmodelElement with idShort ExampleSubmodelCollection already exists"
@@ -471,10 +461,8 @@ def test_post_and_delete_submodel_element_in_submodel_element(self):
471461
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"),
472462
submodel_identifier=string_to_base64url(self.example_submodel.id),
473463
id_short_path="ExampleSubmodelCollection")
474-
retrieved_submodel_element_parsed = AASClientTest._parse_object(object=retrieved_submodel_element,
475-
encoder=AASToJsonEncoder)
476464
self.aasRepoClient.post_submodel_element_by_path_aas_repository(
477-
body=retrieved_submodel_element_parsed, aas_identifier=string_to_base64url(
465+
body=retrieved_submodel_element, aas_identifier=string_to_base64url(
478466
"https://acplt.org/Test_AssetAdministrationShell"), submodel_identifier=string_to_base64url(
479467
self.example_submodel.id), id_short_path="ExampleSubmodelCollection")
480468
retrieved_submodel_element_new = self.aasRepoClient.get_submodel_element_by_path_aas_repository(
@@ -493,10 +481,8 @@ def test_post_submodel_element_in_submodel_element_errors(self):
493481
aas_identifier=string_to_base64url("https://acplt.org/Test_AssetAdministrationShell"),
494482
submodel_identifier=string_to_base64url(self.example_submodel.id),
495483
id_short_path="ExampleSubmodelCollection")
496-
retrieved_submodel_element_parsed = AASClientTest._parse_object(object=retrieved_submodel_element,
497-
encoder=AASToJsonEncoder)
498484
self.aasRepoClient.post_submodel_element_by_path_aas_repository(
499-
body=retrieved_submodel_element_parsed, aas_identifier=string_to_base64url(
485+
body=retrieved_submodel_element, aas_identifier=string_to_base64url(
500486
"https://acplt.org/Test_AssetAdministrationShell"), submodel_identifier=string_to_base64url(
501487
self.example_submodel.id), id_short_path="ExampleSubmodelCollection")
502488
self._assert_api_exception(

0 commit comments

Comments
 (0)