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

adapter.xml: minor improvements #252

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions basyx/aas/adapter/xml/xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ def _failsafe_construct_mandatory(element: etree.Element, constructor: Callable[
"""
constructed = _failsafe_construct(element, constructor, False, **kwargs)
if constructed is None:
raise TypeError("The result of a non-failsafe _failsafe_construct() call was None! "
"This is a bug in the Eclipse BaSyx Python SDK XML deserialization, please report it!")
raise AssertionError("The result of a non-failsafe _failsafe_construct() call was None! "
"This is a bug in the Eclipse BaSyx Python SDK XML deserialization, please report it!")
return constructed


Expand Down
16 changes: 16 additions & 0 deletions test/adapter/xml/test_xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,22 @@ def test_read_aas_xml_element(self) -> None:
submodel = read_aas_xml_element(bytes_io, XMLConstructables.SUBMODEL)
self.assertIsInstance(submodel, model.Submodel)

def test_no_namespace_prefix(self) -> None:
def xml(id_: str) -> str:
return f"""
<environment xmlns="{XML_NS_MAP["aas"]}">
<submodels>
<submodel>
<id>{id_}</id>
</submodel>
</submodels>
</environment>
"""

self._assertInExceptionAndLog(xml(""), f'{{{XML_NS_MAP["aas"]}}}id on line 5 has no text', KeyError,
logging.ERROR)
read_aas_xml_file(io.StringIO(xml("urn:x-test:test-submodel")))


class XmlDeserializationStrippedObjectsTest(unittest.TestCase):
def test_stripped_qualifiable(self) -> None:
Expand Down
Loading