Skip to content
Snippets Groups Projects
Commit 7a38b6be authored by TorbenD's avatar TorbenD
Browse files

model: make description to empy dict instead of None

parent f0174cf5
No related branches found
No related tags found
1 merge request!4Data checker
Pipeline #232857 failed
......@@ -320,8 +320,6 @@ class AASFromJsonDecoder(json.JSONDecoder):
logger.error(error_message, exc_info=e)
else:
raise type(e)(error_message) from e
if ret == {}:
ret = None
return ret
@classmethod
......
......@@ -63,7 +63,7 @@ class View(base.Referable, base.HasSemantics):
self.id_short = id_short
self.contained_element: Set[base.AASReference] = set() if contained_element is None else contained_element
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.semantic_id: Optional[base.Reference] = semantic_id
......@@ -116,7 +116,7 @@ class Asset(base.Identifiable):
self.identification: base.Identifier = identification
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.administration: Optional[base.AdministrativeInformation] = administration
self.asset_identification_model: Optional[base.AASReference["submodel.Submodel"]] = asset_identification_model
......@@ -171,7 +171,7 @@ class AssetAdministrationShell(base.Identifiable, base.Namespace):
self.identification: base.Identifier = identification
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.administration: Optional[base.AdministrativeInformation] = administration
self.derived_from: Optional[base.AASReference["AssetAdministrationShell"]] = derived_from
......
......@@ -401,8 +401,8 @@ class Referable(metaclass=abc.ABCMeta):
def __init__(self):
super().__init__()
self.id_short: Optional[str] = ""
self.category: Optional[str] = None
self.description: Optional[LangStringSet] = None
self.category: Optional[str] = ""
self.description: Optional[LangStringSet] = set()
# We use a Python reference to the parent Namespace instead of a Reference Object, as specified. This allows
# simpler and faster navigation/checks and it has no effect in the serialized data formats anyway.
self.parent: Optional[Namespace] = None
......@@ -1051,37 +1051,3 @@ class DataSpecificationContent(metaclass=abc.ABCMeta):
<<abstract>>
"""
pass
class DataSpecification(Identifiable, DataSpecificationContent, metaclass=abc.ABCMeta):
"""
A DataSpecification to be referenced by model.aas.ConceptDescription
<<abstract>>
"""
def __init__(self,
administration: AdministrativeInformation,
identification: Identifier,
id_short: str = "",
category: Optional[str] = None,
description: Optional[LangStringSet] = None,
parent: Optional[Namespace] = None):
"""
Initializer of DataSpecification
:param administration: Administrative information of an identifiable element. (from base.Identifiable)
:param identification: The globally unique identification of the element. (from base.Identifiable)
:param id_short: Identifying string of the element within its name space. (from base.Referable)
:param category: The category is a value that gives further meta information w.r.t. to the class of the element.
It affects the expected existence of attributes and the applicability of constraints.
(from base.Referable)
:param description: Description or comments on the element. (from base.Referable)
:param parent: Reference to the next referable parent element of the element. (from base.Referable)
"""
super().__init__()
self.administration: AdministrativeInformation = administration
self.identification: Identifier = identification
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[LangStringSet] = description
self.parent: Optional[Namespace] = parent
......@@ -48,7 +48,7 @@ class ConceptDescription(base.Identifiable):
self.is_case_of: Set[base.Reference] = set() if is_case_of is None else is_case_of
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.administration: Optional[base.AdministrativeInformation] = administration
......@@ -85,7 +85,7 @@ class ConceptDictionary(base.Referable):
super().__init__()
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.concept_description: Set[base.AASReference[ConceptDescription]] = \
set() if concept_description is None else concept_description
......
......@@ -62,7 +62,7 @@ class SubmodelElement(base.Referable, base.Qualifiable, base.HasSemantics, base.
super().__init__()
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.semantic_id: Optional[base.Reference] = semantic_id
self.qualifier: Set[base.Constraint] = set() if qualifier is None else qualifier
......@@ -117,7 +117,7 @@ class Submodel(base.Identifiable, base.HasSemantics, base.HasKind, base.Qualifia
self.submodel_element = base.NamespaceSet(self, submodel_element)
self.id_short = id_short
self.category: Optional[str] = category
self.description: Optional[base.LangStringSet] = description
self.description: Optional[base.LangStringSet] = dict() if description is None else description
self.parent: Optional[base.Namespace] = parent
self.administration: Optional[base.AdministrativeInformation] = administration
self.semantic_id: Optional[base.Reference] = semantic_id
......
......@@ -153,11 +153,18 @@ class JsonSerializationDeserializationTest6(unittest.TestCase):
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
file.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file, failsafe=False)
checker = AASDataChecker(raise_immediately=True)
file2 = open('myresult.json', 'r', encoding='utf-8')
file2.seek(0)
json_object_store = json_deserialization.read_json_aas_file(file2, failsafe=False)
checker = AASDataChecker(raise_immediately=False)
testCase_for_example_aas.assert_full_example(checker, json_object_store, False)
testCase_for_example_aas_mandatory_attributes.assert_full_example(checker, json_object_store, False)
testCase_for_example_aas_missing_attributes.assert_full_example(checker, json_object_store, False)
testCase_for_example_concept_description.assert_full_example(checker, json_object_store, False)
testCase_for_example_submodel_template.assert_full_example(checker, json_object_store, False)
for result in checker.failed_checks:
print(result)
for result in checker.successful_checks:
print(result)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment