Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the bugfixes from branch main into improve/V30 #172

Merged
merged 8 commits into from
Nov 21, 2023
2 changes: 1 addition & 1 deletion basyx/aas/adapter/xml/xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _tag_replace_namespace(tag: str, nsmap: Dict[str, str]) -> str:
"""
split = tag.split("}")
for prefix, namespace in nsmap.items():
if namespace == split[0][1:]:
if prefix and namespace == split[0][1:]:
return prefix + ":" + split[1]
return tag

Expand Down
5 changes: 3 additions & 2 deletions test/adapter/xml/test_xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_operation_variable_no_submodel_element(self) -> None:
</aas:submodel>
</aas:submodels>
""")
self._assertInExceptionAndLog(xml, "aas:value", KeyError, logging.ERROR)
self._assertInExceptionAndLog(xml, ["aas:value", "has no submodel element"], KeyError, logging.ERROR)

def test_operation_variable_too_many_submodel_elements(self) -> None:
# TODO: simplify this should our suggestion regarding the XML schema get accepted
Expand Down Expand Up @@ -256,6 +256,7 @@ def test_operation_variable_too_many_submodel_elements(self) -> None:
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as context:
read_aas_xml_file(io.BytesIO(xml.encode("utf-8")), failsafe=False)
self.assertIn("aas:value", context.output[0]) # type: ignore
self.assertIn("more than one submodel element", context.output[0])

def test_duplicate_identifier(self) -> None:
xml = _xml_wrap("""
Expand Down Expand Up @@ -306,7 +307,7 @@ def get_clean_store() -> model.DictObjectStore:
with self.assertLogs(logging.getLogger(), level=logging.INFO) as log_ctx:
identifiers = read_aas_xml_file_into(object_store, bytes_io, replace_existing=False, ignore_existing=True)
self.assertEqual(len(identifiers), 0)
self.assertIn("already exists in the object store", log_ctx.output[0]) # type: ignore
self.assertIn("already exists in the object store", log_ctx.output[0])
submodel = object_store.pop()
self.assertIsInstance(submodel, model.Submodel)
self.assertEqual(submodel.id_short, "test123")
Expand Down
Loading