Skip to content

Commit

Permalink
Merge the bugfixes from branch main into improve/V30
Browse files Browse the repository at this point in the history
  • Loading branch information
s-heppner committed Nov 21, 2023
2 parents 0f55c2a + 6d58ca7 commit de82662
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit de82662

Please sign in to comment.