aas-http-client 1.2.0__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/PKG-INFO +1 -1
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/sdk_tools.py +16 -2
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/PKG-INFO +1 -1
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/pyproject.toml +1 -1
- aas_http_client-1.2.2/tests/test_sdk_tools.py +181 -0
- aas_http_client-1.2.0/tests/test_sdk_tools.py +0 -55
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/LICENSE +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/README.md +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/__init__.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/Configuration/config_classes.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/aas_client.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/__init__.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/authentication.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/experimental_implementation.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/shell_implementation.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/shell_registry_implementation.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/sm_implementation.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/implementations/sm_registry_implementation.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/attachment.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/pagination.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/sdk_wrapper.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/demo/demo_process.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/demo/logging_handler.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/__init__.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/encoder.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/http_helper.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/model_builder.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/utilities/version_check.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/SOURCES.txt +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/dependency_links.txt +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/requires.txt +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/top_level.txt +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/setup.cfg +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/tests/test_client.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/tests/test_client_reg.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/tests/test_utils.py +0 -0
- {aas_http_client-1.2.0 → aas_http_client-1.2.2}/tests/test_wrapper.py +0 -0
|
@@ -90,9 +90,23 @@ def convert_to_dict(object: Any) -> dict | None:
|
|
|
90
90
|
|
|
91
91
|
try:
|
|
92
92
|
data_string = json.dumps(object, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
93
|
-
|
|
94
|
-
return model_dict
|
|
93
|
+
return json.loads(data_string)
|
|
95
94
|
except Exception as e:
|
|
96
95
|
_logger.error(f"Encoding error: {e}")
|
|
97
96
|
_logger.error(f"In object: {object}")
|
|
98
97
|
return None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def deep_copy(object: Any) -> Any:
|
|
101
|
+
"""Create a deep copy of a BaSyx SDK framework object.
|
|
102
|
+
|
|
103
|
+
:param submodel_element: BaSyx SDK framework object to copy.
|
|
104
|
+
:return: A deep copy of the BaSyx SDK framework object.
|
|
105
|
+
"""
|
|
106
|
+
submodel_element_dict = convert_to_dict(object)
|
|
107
|
+
|
|
108
|
+
if submodel_element_dict is None:
|
|
109
|
+
_logger.error("Failed to convert submodel element to dictionary for copying.")
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
return convert_to_object(submodel_element_dict)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aas-http-client"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.2"
|
|
8
8
|
description = "Flexible Python HTTP client for communication with various types of AAS servers."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
from basyx.aas import model
|
|
2
|
+
from aas_http_client.utilities import encoder
|
|
3
|
+
import aas_http_client.utilities.model_builder as model_builder
|
|
4
|
+
import aas_http_client.utilities.sdk_tools as sdk_tools
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
SM_ID = "fluid40/sm_sdk_tools_unit_tests"
|
|
8
|
+
SHELL_ID = "fluid40/aas_sdk_tools_unit_tests"
|
|
9
|
+
|
|
10
|
+
@pytest.fixture(scope="module")
|
|
11
|
+
def shared_sm() -> model.Submodel:
|
|
12
|
+
# create a Submodel
|
|
13
|
+
return model_builder.create_base_submodel(identifier=SM_ID, id_short="sm_http_client_unit_tests", display_name="Submodel HTTP Client Unit Tests", description="This is a sample Submodel created for unit testing of the AAS HTTP Client.")
|
|
14
|
+
|
|
15
|
+
@pytest.fixture(scope="module")
|
|
16
|
+
def shared_sm_temp() -> model.Submodel:
|
|
17
|
+
# create a Submodel
|
|
18
|
+
return model_builder.create_base_submodel(identifier=f"{SM_ID}_temp", id_short="sm_http_client_unit_tests", display_name="Submodel HTTP Client Unit Tests", description="This is a sample Submodel created for unit testing of the AAS HTTP Client.")
|
|
19
|
+
|
|
20
|
+
@pytest.fixture(scope="module")
|
|
21
|
+
def shared_sme() -> model.SubmodelElement:
|
|
22
|
+
# create a Submodel
|
|
23
|
+
return model_builder.create_base_submodel_element_property(id_short="sme_http_client_unit_tests", type=model.datatypes.String, value="This is a sample SubmodelElement created for unit testing of the AAS HTTP Client.", display_name="SubmodelElement HTTP Client Unit Tests", description="This is a sample SubmodelElement created for unit testing of the AAS HTTP Client.")
|
|
24
|
+
|
|
25
|
+
@pytest.fixture(scope="module")
|
|
26
|
+
def shared_sme_collection() -> model.SubmodelElementCollection:
|
|
27
|
+
# create a Submodel
|
|
28
|
+
return model_builder.create_base_submodel_element_collection(id_short="sme_collection_http_client_unit_tests", value=[], display_name="SubmodelElementCollection HTTP Client Unit Tests", description="This is a sample SubmodelElementCollection created for unit testing of the AAS HTTP Client.")
|
|
29
|
+
|
|
30
|
+
@pytest.fixture(scope="module")
|
|
31
|
+
def shared_aas() -> model.AssetAdministrationShell:
|
|
32
|
+
# create an AAS
|
|
33
|
+
aas = model_builder.create_base_aas(identifier=SHELL_ID, id_short="aas_http_client_unit_tests", global_asset_identifier=SHELL_ID, display_name="AAS HTTP Client Unit Tests", description="This is a sample AAS created for unit testing of the AAS HTTP Client.")
|
|
34
|
+
return aas
|
|
35
|
+
|
|
36
|
+
def test_001a_add_sm_to_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
37
|
+
assert len(shared_aas.submodel) == 0
|
|
38
|
+
|
|
39
|
+
result = sdk_tools.add_submodel_to_aas(shared_aas, shared_sm)
|
|
40
|
+
assert result is True
|
|
41
|
+
assert len(shared_aas.submodel) == 1
|
|
42
|
+
|
|
43
|
+
assert shared_sm.id in sdk_tools.get_submodel_ids(shared_aas)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_001b_add_sm_to_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
47
|
+
assert len(shared_aas.submodel) == 1
|
|
48
|
+
|
|
49
|
+
result = sdk_tools.add_submodel_to_aas(shared_aas, shared_sm)
|
|
50
|
+
assert result is False
|
|
51
|
+
assert len(shared_aas.submodel) == 1
|
|
52
|
+
|
|
53
|
+
def test_002a_remove_sm_from_shell(shared_aas: model.AssetAdministrationShell, shared_sm_temp: model.Submodel):
|
|
54
|
+
assert len(shared_aas.submodel) == 1
|
|
55
|
+
|
|
56
|
+
result = sdk_tools.remove_submodel_from_aas(shared_aas, shared_sm_temp)
|
|
57
|
+
assert result is False
|
|
58
|
+
assert len(shared_aas.submodel) == 1
|
|
59
|
+
|
|
60
|
+
def test_002b_remove_sm_from_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
61
|
+
assert len(shared_aas.submodel) == 1
|
|
62
|
+
|
|
63
|
+
result = sdk_tools.remove_submodel_from_aas(shared_aas, shared_sm)
|
|
64
|
+
assert result is True
|
|
65
|
+
assert len(shared_aas.submodel) == 0
|
|
66
|
+
|
|
67
|
+
def test_003_get_submodel_ids(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
68
|
+
# Add the Submodel to the AAS
|
|
69
|
+
sdk_tools.add_submodel_to_aas(shared_aas, shared_sm)
|
|
70
|
+
|
|
71
|
+
# Get the submodel IDs
|
|
72
|
+
submodel_ids = sdk_tools.get_submodel_ids(shared_aas)
|
|
73
|
+
|
|
74
|
+
# Check that the ID of the added Submodel is in the list of submodel IDs
|
|
75
|
+
assert shared_sm.id in submodel_ids
|
|
76
|
+
|
|
77
|
+
# Clean up by removing the Submodel from the AAS
|
|
78
|
+
sdk_tools.remove_submodel_from_aas(shared_aas, shared_sm)
|
|
79
|
+
|
|
80
|
+
def test_004a_convert_to_dict(shared_aas: model.AssetAdministrationShell):
|
|
81
|
+
# Convert the AAS to a dictionary
|
|
82
|
+
aas_dict = sdk_tools.convert_to_dict(shared_aas)
|
|
83
|
+
|
|
84
|
+
# Check that the result is a dictionary
|
|
85
|
+
assert isinstance(aas_dict, dict)
|
|
86
|
+
|
|
87
|
+
# Check that the dictionary contains expected keys
|
|
88
|
+
assert "id" in aas_dict
|
|
89
|
+
assert "idShort" in aas_dict
|
|
90
|
+
assert "modelType" in aas_dict
|
|
91
|
+
assert aas_dict["modelType"] == "AssetAdministrationShell"
|
|
92
|
+
|
|
93
|
+
def test_004b_convert_to_dict(shared_sm: model.Submodel):
|
|
94
|
+
# Convert the Submodel to a dictionary
|
|
95
|
+
sm_dict = sdk_tools.convert_to_dict(shared_sm)
|
|
96
|
+
|
|
97
|
+
# Check that the result is a dictionary
|
|
98
|
+
assert isinstance(sm_dict, dict)
|
|
99
|
+
|
|
100
|
+
# Check that the dictionary contains expected keys
|
|
101
|
+
assert "id" in sm_dict
|
|
102
|
+
assert "idShort" in sm_dict
|
|
103
|
+
assert "modelType" in sm_dict
|
|
104
|
+
assert sm_dict["modelType"]== "Submodel"
|
|
105
|
+
|
|
106
|
+
def test_004c_convert_to_dict():
|
|
107
|
+
# Convert an empty dictionary
|
|
108
|
+
result = sdk_tools.convert_to_dict(None)
|
|
109
|
+
|
|
110
|
+
# Check that the result is None
|
|
111
|
+
assert result is None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_005a_convert_to_object(shared_aas: model.AssetAdministrationShell):
|
|
115
|
+
# Convert None
|
|
116
|
+
aas_dict = sdk_tools.convert_to_dict(shared_aas)
|
|
117
|
+
|
|
118
|
+
assert aas_dict is not None
|
|
119
|
+
assert isinstance(aas_dict, dict)
|
|
120
|
+
|
|
121
|
+
result = sdk_tools.convert_to_object(aas_dict)
|
|
122
|
+
|
|
123
|
+
# Check that the result is an AssetAdministrationShell object
|
|
124
|
+
assert isinstance(result, model.AssetAdministrationShell)
|
|
125
|
+
|
|
126
|
+
def test_005b_convert_to_object(shared_sm: model.Submodel):
|
|
127
|
+
# Convert None
|
|
128
|
+
sm_dict = sdk_tools.convert_to_dict(shared_sm)
|
|
129
|
+
|
|
130
|
+
assert sm_dict is not None
|
|
131
|
+
assert isinstance(sm_dict, dict)
|
|
132
|
+
|
|
133
|
+
result = sdk_tools.convert_to_object(sm_dict)
|
|
134
|
+
|
|
135
|
+
# Check that the result is a Submodel object
|
|
136
|
+
assert isinstance(result, model.Submodel)
|
|
137
|
+
|
|
138
|
+
def test_005c_convert_to_object():
|
|
139
|
+
# Convert None
|
|
140
|
+
result = sdk_tools.convert_to_object({})
|
|
141
|
+
|
|
142
|
+
# Check that the result is None
|
|
143
|
+
assert result is None
|
|
144
|
+
|
|
145
|
+
def test_006a_copy(shared_aas: model.AssetAdministrationShell):
|
|
146
|
+
copied_element = sdk_tools.deep_copy(shared_aas)
|
|
147
|
+
|
|
148
|
+
assert copied_element is not None
|
|
149
|
+
assert isinstance(copied_element, model.AssetAdministrationShell)
|
|
150
|
+
|
|
151
|
+
copied_aas: model.AssetAdministrationShell = copied_element
|
|
152
|
+
assert copied_aas.id == shared_aas.id
|
|
153
|
+
assert copied_aas.id_short == shared_aas.id_short
|
|
154
|
+
|
|
155
|
+
def test_006b_copy(shared_sm: model.Submodel):
|
|
156
|
+
copied_element = sdk_tools.deep_copy(shared_sm)
|
|
157
|
+
|
|
158
|
+
assert copied_element is not None
|
|
159
|
+
assert isinstance(copied_element, model.Submodel)
|
|
160
|
+
|
|
161
|
+
copied_sm: model.Submodel = copied_element
|
|
162
|
+
assert copied_sm.id == shared_sm.id
|
|
163
|
+
assert copied_sm.id_short == shared_sm.id_short
|
|
164
|
+
|
|
165
|
+
def test_006c_copy(shared_sme: model.SubmodelElement):
|
|
166
|
+
copied_element = sdk_tools.deep_copy(shared_sme)
|
|
167
|
+
|
|
168
|
+
assert copied_element is not None
|
|
169
|
+
assert isinstance(copied_element, model.SubmodelElement)
|
|
170
|
+
|
|
171
|
+
copied_sme: model.SubmodelElement = copied_element
|
|
172
|
+
assert copied_sme.id_short == shared_sme.id_short
|
|
173
|
+
|
|
174
|
+
def test_006d_copy(shared_sme_collection: model.SubmodelElementCollection):
|
|
175
|
+
copied_element = sdk_tools.deep_copy(shared_sme_collection)
|
|
176
|
+
|
|
177
|
+
assert copied_element is not None
|
|
178
|
+
assert isinstance(copied_element, model.SubmodelElementCollection)
|
|
179
|
+
|
|
180
|
+
copied_sme_collection: model.SubmodelElementCollection = copied_element
|
|
181
|
+
assert copied_sme_collection.id_short == shared_sme_collection.id_short
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
from basyx.aas import model
|
|
2
|
-
from aas_http_client.utilities import encoder
|
|
3
|
-
import aas_http_client.utilities.model_builder as model_builder
|
|
4
|
-
import aas_http_client.utilities.sdk_tools as sdk_tools
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
SM_ID = "fluid40/sm_sdk_tools_unit_tests"
|
|
8
|
-
SHELL_ID = "fluid40/aas_sdk_tools_unit_tests"
|
|
9
|
-
|
|
10
|
-
@pytest.fixture(scope="module")
|
|
11
|
-
def shared_sm() -> model.Submodel:
|
|
12
|
-
# create a Submodel
|
|
13
|
-
return model_builder.create_base_submodel(identifier=SM_ID, id_short="sm_http_client_unit_tests", display_name="Submodel HTTP Client Unit Tests", description="This is a sample Submodel created for unit testing of the AAS HTTP Client.")
|
|
14
|
-
|
|
15
|
-
@pytest.fixture(scope="module")
|
|
16
|
-
def shared_sm_temp() -> model.Submodel:
|
|
17
|
-
# create a Submodel
|
|
18
|
-
return model_builder.create_base_submodel(identifier=f"{SM_ID}_temp", id_short="sm_http_client_unit_tests", display_name="Submodel HTTP Client Unit Tests", description="This is a sample Submodel created for unit testing of the AAS HTTP Client.")
|
|
19
|
-
|
|
20
|
-
@pytest.fixture(scope="module")
|
|
21
|
-
def shared_aas() -> model.AssetAdministrationShell:
|
|
22
|
-
# create an AAS
|
|
23
|
-
aas = model_builder.create_base_aas(identifier=SHELL_ID, id_short="aas_http_client_unit_tests", global_asset_identifier=SHELL_ID, display_name="AAS HTTP Client Unit Tests", description="This is a sample AAS created for unit testing of the AAS HTTP Client.")
|
|
24
|
-
return aas
|
|
25
|
-
|
|
26
|
-
def test_001a_add_sm_to_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
27
|
-
assert len(shared_aas.submodel) == 0
|
|
28
|
-
|
|
29
|
-
result = sdk_tools.add_submodel_to_aas(shared_aas, shared_sm)
|
|
30
|
-
assert result is True
|
|
31
|
-
assert len(shared_aas.submodel) == 1
|
|
32
|
-
|
|
33
|
-
assert shared_sm.id in sdk_tools.get_submodel_ids(shared_aas)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_001b_add_sm_to_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
37
|
-
assert len(shared_aas.submodel) == 1
|
|
38
|
-
|
|
39
|
-
result = sdk_tools.add_submodel_to_aas(shared_aas, shared_sm)
|
|
40
|
-
assert result is False
|
|
41
|
-
assert len(shared_aas.submodel) == 1
|
|
42
|
-
|
|
43
|
-
def test_002a_remove_sm_from_shell(shared_aas: model.AssetAdministrationShell, shared_sm_temp: model.Submodel):
|
|
44
|
-
assert len(shared_aas.submodel) == 1
|
|
45
|
-
|
|
46
|
-
result = sdk_tools.remove_submodel_from_aas(shared_aas, shared_sm_temp)
|
|
47
|
-
assert result is False
|
|
48
|
-
assert len(shared_aas.submodel) == 1
|
|
49
|
-
|
|
50
|
-
def test_002b_remove_sm_from_shell(shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
51
|
-
assert len(shared_aas.submodel) == 1
|
|
52
|
-
|
|
53
|
-
result = sdk_tools.remove_submodel_from_aas(shared_aas, shared_sm)
|
|
54
|
-
assert result is True
|
|
55
|
-
assert len(shared_aas.submodel) == 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/client/aas_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/attachment.py
RENAMED
|
File without changes
|
{aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/pagination.py
RENAMED
|
File without changes
|
{aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client/classes/wrapper/sdk_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_http_client-1.2.0 → aas_http_client-1.2.2}/aas_http_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|