5.5. data._helper - Helper Classes for AAS Class Comparison
Helper classes for checking two objects for completeness and correctness and reporting the check results.
Warning
This module is intended for internal use only.
- class AASDataChecker(check_extensions: bool = True, **kwargs)
- check_annotated_relationship_element_equal(object_: AnnotatedRelationshipElement, expected_value: AnnotatedRelationshipElement)
Checks if the given AnnotatedRelationshipElement objects are equal
- Parameters:
object – Given AnnotatedRelationshipElement object to check
expected_value – expected AnnotatedRelationshipElement object
- Returns:
- check_asset_administration_shell_equal(object_: AssetAdministrationShell, expected_value: AssetAdministrationShell)
Checks if the given AssetAdministrationShell objects are equal
- Parameters:
object – Given AssetAdministrationShell object to check
expected_value – expected AssetAdministrationShell object
- Returns:
- check_asset_information_equal(object_: AssetInformation, expected_value: AssetInformation)
Checks if the given AssetInformation objects are equal
- Parameters:
object – Given AssetInformation object to check
expected_value – expected AssetInformation object
- Returns:
- check_attribute_equal(object_: object, attribute_name: str, expected_value: object, **kwargs) bool
Checks if the value of the attribute in
object_is the same asexpected_valueand adds / stores the check result for later analysis.- Parameters:
object – The object of which the attribute shall be checked
attribute_name – The name of the attribute in the given object which shall be checked
expected_value – The expected value of the attribute
kwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- check_attribute_is_none(object_: object, attribute_name: str, **kwargs) bool
Checks if the value of the attribute in
object_isNoneand adds / stores the check result for later analysis.- Parameters:
object – The object of which the attribute shall be checked
attribute_name – The name of the attribute in the given object which shall be checked
kwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- check_basic_event_element_equal(object_: BasicEventElement, expected_value: BasicEventElement)
Checks if the given BasicEventElement objects are equal
- Parameters:
object – Given BasicEventElement object to check
expected_value – expected BasicEventElement object
- Returns:
- check_blob_equal(object_: Blob, expected_value: Blob)
Checks if the given Blob objects are equal
- Parameters:
object – Given Blob object to check
expected_value – expected Blob object
- Returns:
- check_capability_equal(object_: Capability, expected_value: Capability)
Checks if the given Capability objects are equal
- Parameters:
object – Given Capability object to check
expected_value – expected Capability object
- Returns:
- check_concept_description_equal(object_: ConceptDescription, expected_value: ConceptDescription)
Checks if the given ConceptDescription objects are equal
- Parameters:
object – Given ConceptDescription object to check
expected_value – expected ConceptDescription object
- Returns:
- check_contained_element_length(object_: object, attribute_name: str, class_name: Type, length: int, **kwargs) bool
Checks if the
object_haslenghtelements of classclass_namein attributeattribute_nameand adds / stores the check result for later analysis.- Parameters:
object – The object of which the attribute shall be checked
attribute_name – The name of the attribute in the given object which shall be checked
class_name – The class name to decide which objects in the attribute shall be count
length – The expected length of the attribute
kwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- check_data_specification_content_equal(object_: DataSpecificationContent, expected_value: DataSpecificationContent)
Checks if the given DataSpecificationContent objects are equal
- Parameters:
object – Given DataSpecificationContent object to check
expected_value – expected DataSpecificationContent object
- Returns:
- check_element_in(object_: Referable, parent: object, **kwargs) bool
Checks if
object_exist inparentand adds / stores the check result for later analysis.- Parameters:
object – The object which shall be in parent
parent – The parent in which
object_shall be existkwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- check_entity_equal(object_: Entity, expected_value: Entity)
Checks if the given Entity objects are equal
- Parameters:
object – Given Entity object to check
expected_value – expected Entity object
- Returns:
- check_file_equal(object_: File, expected_value: File)
Checks if the given File objects are equal
- Parameters:
object – Given File object to check
expected_value – expected File object
- Returns:
- check_is_instance(object_: object, class_name: Type, **kwargs) bool
Checks if
object_is of typeclass_nameand adds / stores the check result for later analysis.- Parameters:
object – The object of which the attribute shall be checked
class_name – The class name which the
object_shall bekwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- check_multi_language_property_equal(object_: MultiLanguageProperty, expected_value: MultiLanguageProperty)
Checks if the given MultiLanguageProperty objects are equal
- Parameters:
object – Given MultiLanguageProperty object to check
expected_value – expected MultiLanguageProperty object
- Returns:
- check_object_store(obj_store_1: DictObjectStore, obj_store_2: DictObjectStore)
Checks if the given object stores are equal
- Parameters:
obj_store_1 – Given object store to check
obj_store_2 – expected object store
- Returns:
- check_operation_equal(object_: Operation, expected_value: Operation)
Checks if the given Operation objects are equal
- Parameters:
object – Given Operation object to check
expected_value – expected Operation object
- Returns:
- check_property_equal(object_: Property, expected_value: Property)
Checks if the given Property objects are equal
- Parameters:
object – Given property object to check
expected_value – expected property object
- Returns:
- check_range_equal(object_: Range, expected_value: Range)
Checks if the given Range objects are equal
- Parameters:
object – Given Range object to check
expected_value – expected Range object
- Returns:
- check_reference_element_equal(object_: ReferenceElement, expected_value: ReferenceElement)
Checks if the given ReferenceElement objects are equal
- Parameters:
object – Given ReferenceElement object to check
expected_value – expected ReferenceElement object
- Returns:
- check_relationship_element_equal(object_: RelationshipElement, expected_value: RelationshipElement)
Checks if the given RelationshipElement objects are equal
- Parameters:
object – Given RelationshipElement object to check
expected_value – expected RelationshipElement object
- Returns:
- check_resource_equal(object_: Resource, expected_value: Resource)
Checks if the given Resource objects are equal
- Parameters:
object – Given Resource object to check
expected_value – expected Resource object
- Returns:
- check_specific_asset_id(object_: SpecificAssetId, expected_value: SpecificAssetId)
Checks if the given SpecificAssetId objects are equal
- Parameters:
object – Given SpecificAssetId object to check
expected_value – expected SpecificAssetId object
- Returns:
- check_submodel_element_collection_equal(object_: SubmodelElementCollection, expected_value: SubmodelElementCollection)
Checks if the given SubmodelElementCollection objects are equal
- Parameters:
object – Given SubmodelElementCollection object to check
expected_value – expected SubmodelElementCollection object
- Returns:
- check_submodel_element_list_equal(object_: SubmodelElementList, expected_value: SubmodelElementList)
Checks if the given SubmodelElementList objects are equal
- Parameters:
object – Given SubmodelElementList object to check
expected_value – expected SubmodelElementList object
- Returns:
- class CheckResult(expectation, result, data)
- class DataChecker(raise_immediately: bool = False)
A helper class to perform multiple checks/assertions of given data and report the result.
Typical usage:
data = {'a': 1, 'b': 2} dc = DataChecker() dc.check(len(data) > 0, "data is not empty") if dc.check('a' in data, "a is in data", keys=list(data.keys())): dc.check(data['a'] == data['b'], "a == b", a=data['a'], b=data['b']) dc.check(data['a'] > 0, "a is positive", a=data['a']) for result in dc.failed_checks: print(result)
- check(expression: bool, expectation: str, **kwargs) bool
Checks if
expressionis True and adds / stores the check result for later analysis.- Parameters:
expression – The boolean to be checked for
expectation – A string describing, what the data was expected to look like (for later listing of successful and failed checks)
kwargs – Relevant values to add to the check result for further analysis (e.g. the compared values)
- Returns:
The value of expression to be used in control statements
- extend(other: DataChecker) None
Extend the list of check results with another DataChecker’s check results
- property failed_checks: Iterator[CheckResult]
- property successful_checks: Iterator[CheckResult]