Skip to content
Snippets Groups Projects
Commit dffc1fa1 authored by Michael Thies's avatar Michael Thies
Browse files

Merge branch 'improve/republish_adapter_functions' into 'master'

adapter: re-publish reader/writer functions

Closes #65

See merge request acplt/pyaas!23
parents fbe3f911 f37dc315
No related branches found
No related tags found
1 merge request!23adapter: re-publish reader/writer functions
Pipeline #268074 passed
Showing
with 90 additions and 81 deletions
......@@ -87,12 +87,12 @@ submodel.submodel_element.add(property)
Serialize the `Submodel` to XML:
```python
import aas.adapter.xml.xml_serialization
from aas.adapter.xml import write_aas_xml_file
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(submodel)
with open('Simple_Submodel.xml', 'w', encoding='utf-8') as f:
aas.adapter.xml.xml_serialization.write_aas_xml_file(file=f, data=data)
write_aas_xml_file(file=f, data=data)
```
......
"""
This package contains different kind of adapter
This package contains different kinds of adapters.
json
This package offers an adapter for serialization and deserialization of PyAAS objects to/from JSON
This package offers an adapter for serialization and deserialization of PyAAS objects to/from JSON.
xml
This package offers an adapter for serialization and deserialization of PyAAS objects to/from XML.
"""
......@@ -31,8 +31,7 @@ import re
from typing import Dict, Tuple, IO, Union, List, Set, Optional
from .. import model
from .json.json_deserialization import read_json_aas_file
from .json.json_serialization import write_aas_json_file
from .json import read_aas_json_file, write_aas_json_file
import pyecma376_2
from ..util import traversal
......@@ -212,7 +211,7 @@ class AASXReader:
or content_type == "" and extension == "json":
logger.debug("Parsing AAS objects from JSON stream in OPC part {} ...".format(part_name))
with self.reader.open_part(part_name) as p:
return read_json_aas_file(io.TextIOWrapper(p, encoding='utf-8-sig'))
return read_aas_json_file(io.TextIOWrapper(p, encoding='utf-8-sig'))
else:
logger.error("Could not determine part format of AASX part {} (Content Type: {}, extension: {}"
.format(part_name, content_type, extension))
......
......@@ -50,7 +50,7 @@ import threading
import logging
from .. import model
from .json import json_serialization, json_deserialization
from .json import StrictAASFromJsonDecoder, AASToJsonEncoder
logger = logging.getLogger(__name__)
......@@ -194,7 +194,7 @@ class CouchDBObjectStore(model.AbstractObjectStore):
"""
logger.debug("Adding object %s to CouchDB database ...", repr(x))
# Serialize data
data = json.dumps({'data': x}, cls=json_serialization.AASToJsonEncoder)
data = json.dumps({'data': x}, cls=AASToJsonEncoder)
# Create and issue HTTP request (raises HTTPError on status != 200)
request = urllib.request.Request(
......@@ -222,7 +222,7 @@ class CouchDBObjectStore(model.AbstractObjectStore):
logger.debug("Committing changes of object %s based on revision %s to CouchDB database ...",
repr(x), x.couchdb_revision)
# Serialize data
data = json.dumps({'data': x, '_rev': x.couchdb_revision}, cls=json_serialization.AASToJsonEncoder)
data = json.dumps({'data': x, '_rev': x.couchdb_revision}, cls=AASToJsonEncoder)
# Create and issue HTTP request (raises HTTPError on status != 200)
request = urllib.request.Request(
......@@ -468,7 +468,7 @@ class CouchDBSubmodel(model.Submodel, CouchDBIdentifiable):
pass
class CouchDBJSONDecoder(json_deserialization.StrictAASFromJsonDecoder):
class CouchDBJSONDecoder(StrictAASFromJsonDecoder):
"""
Special json.JSONDecoder class for deserializing AAS objects received from the CouchDB server
......
......@@ -12,3 +12,6 @@ json_deserialization.py
PyI40AAS object. A function `read_json_aas_file()` is provided to read all AAS objects within a JSON file and return
them as PyI40AAS ObjectStore.
"""
from .json_serialization import AASToJsonEncoder, write_aas_json_file, object_store_to_json
from .json_deserialization import StrictAASFromJsonDecoder, AASFromJsonDecoder, read_aas_json_file
......@@ -675,7 +675,7 @@ class StrictAASFromJsonDecoder(AASFromJsonDecoder):
failsafe = False
def read_json_aas_file(file: IO, failsafe: bool = True) -> model.DictObjectStore:
def read_aas_json_file(file: IO, failsafe: bool = True) -> model.DictObjectStore:
"""
Read an Asset Adminstration Shell JSON file according to 'Details of the Asset Administration Shell', chapter 5.5
......
"""
This package contains functionality for serialization and deserialization of PyI40AAS objects into/from XML.
xml_serialization:
The module offers a function to write an ObjectStore to a given file.
xml_deserialization.py
The module offers a function to create an ObjectStore from a given xml document.
"""
from .xml_serialization import write_aas_xml_file
......@@ -19,7 +19,7 @@ import argparse
import logging
from aas.compliance_tool import compliance_check_json as compliance_tool_json
from aas.adapter.json import json_serialization
from aas.adapter.json import write_aas_json_file
from aas.examples.data import create_example
from aas.compliance_tool.state_manager import ComplianceToolStateManager, Status
......@@ -68,7 +68,7 @@ def main():
manager.add_step('Write data to file')
if args.json:
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
manager.set_step_status(Status.SUCCESS)
elif args.xml:
# Todo: if xml serialization is done add code here
......
......@@ -146,7 +146,7 @@ def check_deserialization(file_path: str, state_manager: ComplianceToolStateMana
state_manager.add_step('Read {} file and check if it is conform to the json schema'.format(file_info))
else:
state_manager.add_step('Read file and check if it is conform to the json schema')
obj_store = json_deserialization.read_json_aas_file(file_to_be_checked, True)
obj_store = json_deserialization.read_aas_json_file(file_to_be_checked, True)
state_manager.set_step_status_from_log()
......
......@@ -10,7 +10,7 @@ import json
# Import all PyI40AAS classes from model package
from aas import model
from aas.adapter.json import json_serialization, json_deserialization
from aas.adapter.json import AASToJsonEncoder, read_aas_json_file, write_aas_json_file, object_store_to_json
from aas.model import Asset, AssetAdministrationShell, Submodel
# In this tutorial you get a step by step guide how to serialize objects of the meta model according to
......@@ -58,13 +58,13 @@ aas = AssetAdministrationShell(
# step 2: serialize an object to json and write it to file #
############################################################
# step 2.1: serialize an object to json
# json_serialization.AASToJsonEncoder is a custom JSONDecoder class for serializing Asset Administration Shell data
# AASToJsonEncoder is a custom JSONDecoder class for serializing Asset Administration Shell data
# into the official JSON format according to 'Details of the Asset Administration Shell', chapter 5.5
# serialize an asset administration shell
json_data_object = json.loads(json.dumps(aas, cls=json_serialization.AASToJsonEncoder))
json_data_object = json.loads(json.dumps(aas, cls=AASToJsonEncoder))
# serialize a property
json_data_object = json.loads(json.dumps(submodel.submodel_element.get_referable('ExampleProperty'),
cls=json_serialization.AASToJsonEncoder))
cls=AASToJsonEncoder))
# step 2.2: write json data to file
# define a file stream, here an internal file stream is used. For an external file stream use
# 'open('tutorial.json', 'w', encoding='utf-8')' for opening a json-File to write json data inside
......@@ -82,8 +82,8 @@ obj_store: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
obj_store.add(asset)
obj_store.add(submodel)
obj_store.add(aas)
# serialize the store using the function 'object_store_to_json' of the 'json_serialization' module
json_data_store = json_serialization.object_store_to_json(obj_store)
# serialize the store using the function 'object_store_to_json' of the 'json' module
json_data_store = object_store_to_json(obj_store)
# step 2.2: write json data to file
# define a file stream, here an internal file stream is used. For an external file stream use
# 'open('tutorial.json', 'w', encoding='utf-8')' for opening a json-File to write json data inside
......@@ -93,7 +93,7 @@ json.dump(json_data_store, file_store)
# serialize an object store and write it to a file can be done in one step using the function 'write_aas_json_file'
file_store_2 = io.StringIO()
json_serialization.write_aas_json_file(file=file_store_2, data=obj_store)
write_aas_json_file(file=file_store_2, data=obj_store)
#################################################################################################
# step 4: # read a json string from file and deserialize it into an object store of AAS objects #
......@@ -103,7 +103,7 @@ json_serialization.write_aas_json_file(file=file_store_2, data=obj_store)
# we have to set the file pointer to the beginning cause we are using the same file stream. Normally, you do not need
# to do this.
file_store_2.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file_store_2, failsafe=False)
json_object_store = read_aas_json_file(file_store_2, failsafe=False)
# take a submodel out of the object store, for more details look at 'tutorial_storage.py'
tmp_submodel: Submodel = json_object_store.get_identifiable( # type: ignore
......
......@@ -19,7 +19,7 @@ import io
import json
import logging
import unittest
from aas.adapter.json import json_deserialization
from aas.adapter.json import AASFromJsonDecoder, StrictAASFromJsonDecoder, read_aas_json_file
from aas import model
......@@ -32,9 +32,9 @@ class JsonDeserializationTest(unittest.TestCase):
"conceptDescriptions": []
}"""
with self.assertRaisesRegex(KeyError, r"submodels"):
json_deserialization.read_json_aas_file(io.StringIO(data), False)
read_aas_json_file(io.StringIO(data), False)
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
json_deserialization.read_json_aas_file(io.StringIO(data), True)
read_aas_json_file(io.StringIO(data), True)
self.assertIn("submodels", cm.output[0])
def test_file_format_wrong_list(self) -> None:
......@@ -57,9 +57,9 @@ class JsonDeserializationTest(unittest.TestCase):
]
}"""
with self.assertRaisesRegex(TypeError, r"submodels.*Asset"):
json_deserialization.read_json_aas_file(io.StringIO(data), False)
read_aas_json_file(io.StringIO(data), False)
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
json_deserialization.read_json_aas_file(io.StringIO(data), True)
read_aas_json_file(io.StringIO(data), True)
self.assertIn("submodels", cm.output[0])
self.assertIn("Asset", cm.output[0])
......@@ -74,9 +74,9 @@ class JsonDeserializationTest(unittest.TestCase):
]
}"""
with self.assertRaisesRegex(TypeError, r"submodels.*'foo'"):
json_deserialization.read_json_aas_file(io.StringIO(data), False)
read_aas_json_file(io.StringIO(data), False)
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
json_deserialization.read_json_aas_file(io.StringIO(data), True)
read_aas_json_file(io.StringIO(data), True)
self.assertIn("submodels", cm.output[0])
self.assertIn("'foo'", cm.output[0])
......@@ -100,11 +100,11 @@ class JsonDeserializationTest(unittest.TestCase):
]"""
# In strict mode, we should catch an exception
with self.assertRaisesRegex(KeyError, r"identification"):
json.loads(data, cls=json_deserialization.StrictAASFromJsonDecoder)
json.loads(data, cls=StrictAASFromJsonDecoder)
# In failsafe mode, we should get a log entry and the first Asset entry should be returned as untouched dict
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
parsed_data = json.loads(data, cls=json_deserialization.AASFromJsonDecoder)
parsed_data = json.loads(data, cls=AASFromJsonDecoder)
self.assertIn("identification", cm.output[0])
self.assertIsInstance(parsed_data, list)
self.assertEqual(3, len(parsed_data))
......@@ -143,13 +143,13 @@ class JsonDeserializationTest(unittest.TestCase):
# The broken object should not raise an exception, but log a warning, even in strict mode.
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
with self.assertRaisesRegex(TypeError, r"SubmodelElement.*Asset"):
json.loads(data, cls=json_deserialization.StrictAASFromJsonDecoder)
json.loads(data, cls=StrictAASFromJsonDecoder)
self.assertIn("modelType", cm.output[0])
# In failsafe mode, we should get a log entries for the broken object and the wrong type of the first two
# submodelElements
with self.assertLogs(logging.getLogger(), level=logging.WARNING) as cm:
parsed_data = json.loads(data, cls=json_deserialization.AASFromJsonDecoder)
parsed_data = json.loads(data, cls=AASFromJsonDecoder)
self.assertGreaterEqual(len(cm.output), 3)
self.assertIn("SubmodelElement", cm.output[1])
self.assertIn("SubmodelElement", cm.output[2])
......@@ -168,7 +168,7 @@ class JsonDeserializationDerivingTest(unittest.TestCase):
super().__init__(**kwargs)
self.enhanced_attribute = "fancy!"
class EnhancedAASDecoder(json_deserialization.AASFromJsonDecoder):
class EnhancedAASDecoder(AASFromJsonDecoder):
@classmethod
def _construct_asset(cls, dct):
return super()._construct_asset(dct, object_class=EnhancedAsset)
......
......@@ -15,7 +15,7 @@ import json
import os
from aas import model
from aas.adapter.json import json_serialization
from aas.adapter.json import AASToJsonEncoder, write_aas_json_file
from jsonschema import validate # type: ignore
from aas.examples.data import example_aas_missing_attributes, example_submodel_template, \
......@@ -28,7 +28,7 @@ class JsonSerializationTest(unittest.TestCase):
def test_serialize_object(self) -> None:
test_object = model.Property("test_id_short", model.datatypes.String, category="PARAMETER",
description={"en-us": "Germany", "de": "Deutschland"})
json_data = json.dumps(test_object, cls=json_serialization.AASToJsonEncoder)
json_data = json.dumps(test_object, cls=AASToJsonEncoder)
def test_random_object_serialization(self) -> None:
asset_key = (model.Key(model.KeyElements.ASSET, True, "asset", model.KeyType.CUSTOM),)
......@@ -47,7 +47,7 @@ class JsonSerializationTest(unittest.TestCase):
'submodels': [submodel],
'assets': [],
'conceptDescriptions': [],
}, cls=json_serialization.AASToJsonEncoder)
}, cls=AASToJsonEncoder)
json_data_new = json.loads(json_data)
......@@ -72,7 +72,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
'submodels': [submodel],
'assets': [],
'conceptDescriptions': [],
}, cls=json_serialization.AASToJsonEncoder)
}, cls=AASToJsonEncoder)
json_data_new = json.loads(json_data)
# load schema
......@@ -85,7 +85,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
def test_aas_example_serialization(self) -> None:
data = example_aas.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......@@ -100,7 +100,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_submodel_template.create_example_submodel_template())
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......@@ -114,7 +114,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
def test_full_empty_example_serialization(self) -> None:
data = example_aas_mandatory_attributes.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......@@ -128,7 +128,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
def test_missing_serialization(self) -> None:
data = example_aas_missing_attributes.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......@@ -143,7 +143,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_concept_description.create_iec61360_concept_description())
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......@@ -157,7 +157,7 @@ class JsonSerializationSchemaTest(unittest.TestCase):
def test_full_example_serialization(self) -> None:
data = create_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
with open(JSON_SCHEMA_FILE, 'r') as json_file:
aas_json_schema = json.load(json_file)
......
......@@ -15,7 +15,7 @@ import os
import unittest
from aas import model
from aas.adapter.json import json_serialization, json_deserialization
from aas.adapter.json import AASToJsonEncoder, write_aas_json_file, read_aas_json_file
from aas.examples.data import example_aas_missing_attributes, example_submodel_template, \
example_aas_mandatory_attributes, example_aas, example_concept_description
......@@ -41,22 +41,20 @@ class JsonSerializationDeserializationTest(unittest.TestCase):
'submodels': [submodel],
'assets': [],
'conceptDescriptions': [],
}, cls=json_serialization.AASToJsonEncoder)
}, cls=AASToJsonEncoder)
json_data_new = json.loads(json_data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
json_object_store = json_deserialization.read_json_aas_file(io.StringIO(json_data), failsafe=False)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
json_object_store = read_aas_json_file(io.StringIO(json_data), failsafe=False)
def test_example_serialization_deserialization(self) -> None:
data = example_aas.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
json_object_store = read_aas_json_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
example_aas.check_full_example(checker, json_object_store)
......@@ -65,12 +63,11 @@ class JsonSerializationDeserializationTest2(unittest.TestCase):
def test_example_mandatory_attributes_serialization_deserialization(self) -> None:
data = example_aas_mandatory_attributes.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
json_object_store = read_aas_json_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
example_aas_mandatory_attributes.check_full_example(checker, json_object_store)
......@@ -79,11 +76,10 @@ class JsonSerializationDeserializationTest3(unittest.TestCase):
def test_example_missing_attributes_serialization_deserialization(self) -> None:
data = example_aas_missing_attributes.create_full_example()
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
json_object_store = read_aas_json_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
example_aas_missing_attributes.check_full_example(checker, json_object_store)
......@@ -93,11 +89,10 @@ class JsonSerializationDeserializationTest4(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_submodel_template.create_example_submodel_template())
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
json_object_store = read_aas_json_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
example_submodel_template.check_full_example(checker, json_object_store)
......@@ -107,10 +102,9 @@ class JsonSerializationDeserializationTest5(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_concept_description.create_iec61360_concept_description())
file = io.StringIO()
json_serialization.write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json_deserialization
# module
write_aas_json_file(file=file, data=data)
# try deserializing the json string into a DictObjectStore of AAS objects with help of the json module
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
json_object_store = read_aas_json_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
example_concept_description.check_full_example(checker, json_object_store)
......@@ -14,7 +14,7 @@ from lxml import etree # type: ignore
import os
from aas import model
from aas.adapter.xml import xml_serialization
from aas.adapter.xml import write_aas_xml_file, xml_serialization
from aas.examples.data import example_aas_missing_attributes, example_submodel_template, \
example_aas_mandatory_attributes, example_aas, example_concept_description
......@@ -47,7 +47,7 @@ class XMLSerializationTest(unittest.TestCase):
test_data.add(submodel)
test_file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=test_file, data=test_data)
write_aas_xml_file(file=test_file, data=test_data)
@unittest.skipUnless(os.path.exists(XML_SCHEMA_FILE), "XML Schema not found for validation")
......@@ -69,7 +69,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
test_data.add(submodel)
test_file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=test_file, data=test_data)
write_aas_xml_file(file=test_file, data=test_data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......@@ -82,7 +82,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
def test_full_example_serialization(self) -> None:
data = example_aas.create_full_example()
file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=file, data=data)
write_aas_xml_file(file=file, data=data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......@@ -96,7 +96,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_submodel_template.create_example_submodel_template())
file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=file, data=data)
write_aas_xml_file(file=file, data=data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......@@ -109,7 +109,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
def test_full_empty_example_serialization(self) -> None:
data = example_aas_mandatory_attributes.create_full_example()
file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=file, data=data)
write_aas_xml_file(file=file, data=data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......@@ -122,7 +122,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
def test_missing_serialization(self) -> None:
data = example_aas_missing_attributes.create_full_example()
file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=file, data=data)
write_aas_xml_file(file=file, data=data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......@@ -136,7 +136,7 @@ class XMLSerializationSchemaTest(unittest.TestCase):
data: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
data.add(example_concept_description.create_iec61360_concept_description())
file = io.BytesIO()
xml_serialization.write_aas_xml_file(file=file, data=data)
write_aas_xml_file(file=file, data=data)
# load schema
aas_schema = etree.XMLSchema(file=XML_SCHEMA_FILE)
......
......@@ -15,7 +15,7 @@ import unittest
import aas.compliance_tool
import tempfile
from aas.adapter.json import json_deserialization
from aas.adapter.json import read_aas_json_file
from aas.examples.data import create_example
from aas.examples.data._helper import AASDataChecker
......@@ -145,7 +145,7 @@ class ComplianceToolTest(unittest.TestCase):
self.assertIn('SUCCESS: Write data to file', str(output.stdout))
with open(filename, "r", encoding='utf-8-sig') as f:
json_object_store = json_deserialization.read_json_aas_file(f, failsafe=False)
json_object_store = read_aas_json_file(f, failsafe=False)
data = create_example()
checker = AASDataChecker(raise_immediately=True)
checker.check_object_store(json_object_store, data)
......@@ -207,7 +207,7 @@ class ComplianceToolTest(unittest.TestCase):
self.assertIn('SUCCESS: Write data to file', str(output.stdout))
with open(filename, "r", encoding='utf-8-sig') as f:
json_object_store = json_deserialization.read_json_aas_file(f, failsafe=False)
json_object_store = read_aas_json_file(f, failsafe=False)
data = create_example()
checker = AASDataChecker(raise_immediately=True)
checker.check_object_store(json_object_store, data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment