Skip to content

Commit

Permalink
basyx.aas.examples.data: Add unit test for __init__.py (eclipse-basyx…
Browse files Browse the repository at this point in the history
…#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
Ornella33 authored Jul 12, 2024
1 parent ff35c4e commit 77952c2
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/examples/test__init__.py
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)

0 comments on commit 77952c2

Please sign in to comment.