forked from eclipse-basyx/basyx-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basyx.aas.examples.data: Add unit test for __init__.py (eclipse-basyx…
…#283) Previously, the unittests for `basyx.examples.data.__init__` were missing. This adds the missing unittests in a new `test.examples.test__init__` test file.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2024 the Eclipse BaSyx Authors | ||
# | ||
# This program and the accompanying materials are made available under the terms of the MIT License, available in | ||
# the LICENSE file of this project. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
import unittest | ||
|
||
from basyx.aas import model | ||
from basyx.aas.examples.data import create_example, create_example_aas_binding | ||
|
||
|
||
class TestExampleFunctions(unittest.TestCase): | ||
|
||
def test_create_example(self): | ||
obj_store = create_example() | ||
|
||
# Check that the object store is not empty | ||
self.assertGreater(len(obj_store), 0) | ||
|
||
# Check that the object store contains expected elements | ||
expected_ids = [ | ||
'https://acplt.org/Test_AssetAdministrationShell', | ||
'https://acplt.org/Test_Submodel_Template', | ||
'https://acplt.org/Test_ConceptDescription_Mandatory' | ||
] | ||
for id in expected_ids: | ||
self.assertIsNotNone(obj_store.get_identifiable(id)) | ||
|
||
def test_create_example_aas_binding(self): | ||
obj_store = create_example_aas_binding() | ||
|
||
# Check that the object store is not empty | ||
self.assertGreater(len(obj_store), 0) | ||
|
||
# Check that the object store contains expected elements | ||
aas_id = 'https://acplt.org/Test_AssetAdministrationShell' | ||
sm_id = 'https://acplt.org/Test_Submodel_Template' | ||
cd_id = 'https://acplt.org/Test_ConceptDescription_Mandatory' | ||
|
||
aas = obj_store.get_identifiable(aas_id) | ||
sm = obj_store.get_identifiable(sm_id) | ||
cd = obj_store.get_identifiable(cd_id) | ||
|
||
self.assertIsNotNone(aas) | ||
self.assertIsNotNone(sm) | ||
self.assertIsNotNone(cd) | ||
|
||
# Check types | ||
self.assertIsInstance(aas, model.aas.AssetAdministrationShell) | ||
self.assertIsInstance(sm, model.submodel.Submodel) | ||
self.assertIsInstance(cd, model.concept.ConceptDescription) | ||
|
||
# Check that the submodel is referred by the AAS | ||
self.assertIn(model.ModelReference.from_referable(sm), aas.submodel) |