aas-http-client 0.1.9__tar.gz → 0.1.92__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.
Potentially problematic release.
This version of aas-http-client might be problematic. Click here for more details.
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/PKG-INFO +5 -3
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/README.md +4 -2
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client.egg-info/PKG-INFO +5 -3
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client.egg-info/SOURCES.txt +1 -3
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/pyproject.toml +1 -1
- aas_http_client-0.1.9/tests/test_client_dotnet_server.py +0 -290
- aas_http_client-0.1.9/tests/test_client_java_server.py +0 -263
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/LICENSE +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/__init__.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/client.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/core/encoder.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/core/version_check.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/demo/demo_process.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/demo/logging_handler.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/utilities/__init__.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/utilities/model_builder.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client/wrapper/sdk_wrapper.py +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client.egg-info/dependency_links.txt +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client.egg-info/top_level.txt +0 -0
- {aas_http_client-0.1.9 → aas_http_client-0.1.92}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.92
|
|
4
4
|
Summary: Generic HTTP client for communicating with various types of AAS servers
|
|
5
5
|
Author-email: Daniel Klein <daniel.klein@em.ag>
|
|
6
6
|
License: # :em engineering methods AG Software License
|
|
@@ -127,8 +127,8 @@ Dynamic: license-file
|
|
|
127
127
|
[](https://github.com/fluid40/aas-http-client/actions)
|
|
128
128
|
[](https://pypi.org/project/aas-http-client/)
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
This is a generic HTTP client that can communicate with various types of AAS and submodel repository servers. The client uses Python dictionaries for input and output parameters.
|
|
131
|
+
Additionally, wrappers are provided that work with various AAS frameworks and use the HTTP client as middleware.
|
|
132
132
|
|
|
133
133
|
Currently, wrappers are available for the following frameworks:
|
|
134
134
|
- BaSyx Python SDK
|
|
@@ -149,6 +149,8 @@ Currently, wrappers are available for the following frameworks:
|
|
|
149
149
|
|
|
150
150
|
## ⚡ Quickstart
|
|
151
151
|
|
|
152
|
+
For a detailed introduction, please read [Getting Started](docs/getting_started.md).
|
|
153
|
+
|
|
152
154
|
```bash
|
|
153
155
|
pip install aas-http-client
|
|
154
156
|
````
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
[](https://github.com/fluid40/aas-http-client/actions)
|
|
16
16
|
[](https://pypi.org/project/aas-http-client/)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
This is a generic HTTP client that can communicate with various types of AAS and submodel repository servers. The client uses Python dictionaries for input and output parameters.
|
|
19
|
+
Additionally, wrappers are provided that work with various AAS frameworks and use the HTTP client as middleware.
|
|
20
20
|
|
|
21
21
|
Currently, wrappers are available for the following frameworks:
|
|
22
22
|
- BaSyx Python SDK
|
|
@@ -37,6 +37,8 @@ Currently, wrappers are available for the following frameworks:
|
|
|
37
37
|
|
|
38
38
|
## ⚡ Quickstart
|
|
39
39
|
|
|
40
|
+
For a detailed introduction, please read [Getting Started](docs/getting_started.md).
|
|
41
|
+
|
|
40
42
|
```bash
|
|
41
43
|
pip install aas-http-client
|
|
42
44
|
````
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.92
|
|
4
4
|
Summary: Generic HTTP client for communicating with various types of AAS servers
|
|
5
5
|
Author-email: Daniel Klein <daniel.klein@em.ag>
|
|
6
6
|
License: # :em engineering methods AG Software License
|
|
@@ -127,8 +127,8 @@ Dynamic: license-file
|
|
|
127
127
|
[](https://github.com/fluid40/aas-http-client/actions)
|
|
128
128
|
[](https://pypi.org/project/aas-http-client/)
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
This is a generic HTTP client that can communicate with various types of AAS and submodel repository servers. The client uses Python dictionaries for input and output parameters.
|
|
131
|
+
Additionally, wrappers are provided that work with various AAS frameworks and use the HTTP client as middleware.
|
|
132
132
|
|
|
133
133
|
Currently, wrappers are available for the following frameworks:
|
|
134
134
|
- BaSyx Python SDK
|
|
@@ -149,6 +149,8 @@ Currently, wrappers are available for the following frameworks:
|
|
|
149
149
|
|
|
150
150
|
## ⚡ Quickstart
|
|
151
151
|
|
|
152
|
+
For a detailed introduction, please read [Getting Started](docs/getting_started.md).
|
|
153
|
+
|
|
152
154
|
```bash
|
|
153
155
|
pip install aas-http-client
|
|
154
156
|
````
|
|
@@ -13,6 +13,4 @@ aas_http_client/demo/demo_process.py
|
|
|
13
13
|
aas_http_client/demo/logging_handler.py
|
|
14
14
|
aas_http_client/utilities/__init__.py
|
|
15
15
|
aas_http_client/utilities/model_builder.py
|
|
16
|
-
aas_http_client/wrapper/sdk_wrapper.py
|
|
17
|
-
tests/test_client_dotnet_server.py
|
|
18
|
-
tests/test_client_java_server.py
|
|
16
|
+
aas_http_client/wrapper/sdk_wrapper.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aas-http-client"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.92"
|
|
8
8
|
description = "Generic HTTP client for communicating with various types of AAS servers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from aas_http_client.client import create_client_by_config, AasHttpClient
|
|
4
|
-
from basyx.aas.model import AssetAdministrationShell, Submodel, MultiLanguageTextType
|
|
5
|
-
import aas_http_client.utilities.model_builder as model_builder
|
|
6
|
-
import json
|
|
7
|
-
import basyx.aas.adapter.json
|
|
8
|
-
|
|
9
|
-
@pytest.fixture(scope="module")
|
|
10
|
-
def client() -> AasHttpClient:
|
|
11
|
-
try:
|
|
12
|
-
file = Path("./tests/server_configs/test_dotnet_server_config.json").resolve()
|
|
13
|
-
|
|
14
|
-
if not file.exists():
|
|
15
|
-
raise FileNotFoundError(f"Configuration file {file} does not exist.")
|
|
16
|
-
|
|
17
|
-
client = create_client_by_config(file, password="")
|
|
18
|
-
except Exception as e:
|
|
19
|
-
raise RuntimeError("Unable to connect to server.")
|
|
20
|
-
|
|
21
|
-
shells = client.get_shells()
|
|
22
|
-
if shells is None:
|
|
23
|
-
raise RuntimeError("No shells found on server. Please check the server configuration.")
|
|
24
|
-
|
|
25
|
-
for shell in shells.get("result", []):
|
|
26
|
-
id = shell.get("id", "")
|
|
27
|
-
client.delete_shells_by_id(id)
|
|
28
|
-
|
|
29
|
-
submodels = client.get_submodels()
|
|
30
|
-
if submodels is None:
|
|
31
|
-
raise RuntimeError("No submodels found on server. Please check the server configuration.")
|
|
32
|
-
|
|
33
|
-
for submodel in submodels.get("result", []):
|
|
34
|
-
id = submodel.get("id", "")
|
|
35
|
-
client.delete_submodels_by_id(id)
|
|
36
|
-
|
|
37
|
-
return client
|
|
38
|
-
|
|
39
|
-
@pytest.fixture(scope="module")
|
|
40
|
-
def shared_sm() -> Submodel:
|
|
41
|
-
# create a Submodel
|
|
42
|
-
return model_builder.create_base_submodel("sm_http_client_unit_tests", "")
|
|
43
|
-
|
|
44
|
-
@pytest.fixture(scope="module")
|
|
45
|
-
def shared_aas(client: AasHttpClient, shared_sm: Submodel) -> AssetAdministrationShell:
|
|
46
|
-
# create an AAS
|
|
47
|
-
aas = model_builder.create_base_ass(id_short="aas_http_client_unit_tests", namespace="")
|
|
48
|
-
|
|
49
|
-
# add Submodel to AAS
|
|
50
|
-
model_builder.add_submodel_to_aas(aas, shared_sm)
|
|
51
|
-
|
|
52
|
-
return aas
|
|
53
|
-
|
|
54
|
-
def test_001_connect(client: AasHttpClient):
|
|
55
|
-
assert client is not None
|
|
56
|
-
|
|
57
|
-
def test_002_get_shells(client: AasHttpClient):
|
|
58
|
-
result = client.get_shells()
|
|
59
|
-
assert result is not None
|
|
60
|
-
shells = result.get("result", [])
|
|
61
|
-
assert len(shells) == 0
|
|
62
|
-
|
|
63
|
-
def test_003_post_shells(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
64
|
-
aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
65
|
-
aas_data = json.loads(aas_data_string)
|
|
66
|
-
result = client.post_shells(aas_data)
|
|
67
|
-
|
|
68
|
-
assert result is not None
|
|
69
|
-
result_id_short = result.get("idShort", "")
|
|
70
|
-
assert result_id_short == shared_aas.id_short
|
|
71
|
-
|
|
72
|
-
get_result = client.get_shells()
|
|
73
|
-
assert get_result is not None
|
|
74
|
-
shells = get_result.get("result", [])
|
|
75
|
-
assert len(shells) == 1
|
|
76
|
-
assert shells[0].get("idShort", "") == shared_aas.id_short
|
|
77
|
-
|
|
78
|
-
def test_004a_get_shell_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
79
|
-
result = client.get_shells_by_id(shared_aas.id)
|
|
80
|
-
|
|
81
|
-
assert result is not None
|
|
82
|
-
assert result.get("idShort", "") == shared_aas.id_short
|
|
83
|
-
|
|
84
|
-
def test_004b_get_shell_by_id_not_found(client: AasHttpClient):
|
|
85
|
-
result = client.get_shells_by_id("non_existent_id")
|
|
86
|
-
|
|
87
|
-
assert result is None
|
|
88
|
-
|
|
89
|
-
def test_005a_put_shells(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
90
|
-
aas = AssetAdministrationShell(id_=shared_aas.asset_information.global_asset_id, asset_information=shared_aas.asset_information)
|
|
91
|
-
aas.id_short = shared_aas.id_short
|
|
92
|
-
|
|
93
|
-
description_text = "Put description for unit tests"
|
|
94
|
-
aas.description = MultiLanguageTextType({"en": description_text})
|
|
95
|
-
aas.submodel = shared_aas.submodel # Keep existing submodels
|
|
96
|
-
|
|
97
|
-
aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
98
|
-
aas_data = json.loads(aas_data_string)
|
|
99
|
-
|
|
100
|
-
result = client.put_shells(shared_aas.id, aas_data)
|
|
101
|
-
|
|
102
|
-
assert result
|
|
103
|
-
|
|
104
|
-
get_result = client.get_shells_by_id(shared_aas.id)
|
|
105
|
-
|
|
106
|
-
assert get_result is not None
|
|
107
|
-
assert get_result.get("idShort", "") == shared_aas.id_short
|
|
108
|
-
assert get_result.get("id", "") == shared_aas.id
|
|
109
|
-
# description must have changed
|
|
110
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
111
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_aas.description.get("en", "")
|
|
112
|
-
# submodels must be retained
|
|
113
|
-
assert len(get_result.get("submodels", [])) == len(shared_aas.submodel)
|
|
114
|
-
|
|
115
|
-
# The display name must be empty
|
|
116
|
-
# currently not working in dotnet
|
|
117
|
-
# assert len(get_result.get("displayName", {})) == 0
|
|
118
|
-
|
|
119
|
-
def test_005b_put_shells_with_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
120
|
-
# put with other ID
|
|
121
|
-
id_short = "put_short_id"
|
|
122
|
-
asset_info = model_builder.create_base_asset_information(id_short)
|
|
123
|
-
aas = AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
|
|
124
|
-
aas.id_short = id_short
|
|
125
|
-
|
|
126
|
-
description_text = {"en": "Updated description for unit tests"}
|
|
127
|
-
aas.description = MultiLanguageTextType(description_text)
|
|
128
|
-
|
|
129
|
-
aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
130
|
-
aas_data = json.loads(aas_data_string)
|
|
131
|
-
|
|
132
|
-
aas_data["id"] = "updated_id" # Ensure the id is included in the update
|
|
133
|
-
|
|
134
|
-
result = client.put_shells(shared_aas.id, aas_data)
|
|
135
|
-
|
|
136
|
-
assert not result
|
|
137
|
-
|
|
138
|
-
def test_006_get_shells_reference_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
139
|
-
result = client.get_shells_reference_by_id(shared_aas.id)
|
|
140
|
-
|
|
141
|
-
assert result
|
|
142
|
-
keys = result.get("keys", [])
|
|
143
|
-
assert len(keys) == 1
|
|
144
|
-
assert keys[0].get("value", "") == shared_aas.id
|
|
145
|
-
|
|
146
|
-
def test_007_get_shells_submodels_by_id_not_posted(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
147
|
-
result = client.get_shells_submodels_by_id(shared_aas.id, shared_sm.id)
|
|
148
|
-
|
|
149
|
-
assert result is None
|
|
150
|
-
|
|
151
|
-
def test_008_get_submodels(client: AasHttpClient):
|
|
152
|
-
result = client.get_submodels()
|
|
153
|
-
assert result
|
|
154
|
-
submodels = result.get("result", [])
|
|
155
|
-
assert len(submodels) == 0
|
|
156
|
-
|
|
157
|
-
def test_009_post_submodels(client: AasHttpClient, shared_sm: Submodel):
|
|
158
|
-
sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
159
|
-
sm_data = json.loads(sm_data_string)
|
|
160
|
-
|
|
161
|
-
result = client.post_submodels(sm_data)
|
|
162
|
-
|
|
163
|
-
assert result is not None
|
|
164
|
-
result_id_short = result.get("idShort", "")
|
|
165
|
-
assert result_id_short == shared_sm.id_short
|
|
166
|
-
|
|
167
|
-
get_result = client.get_submodels()
|
|
168
|
-
assert get_result is not None
|
|
169
|
-
submodels = get_result.get("result", [])
|
|
170
|
-
assert len(submodels) == 1
|
|
171
|
-
assert submodels[0].get("idShort", "") == shared_sm.id_short
|
|
172
|
-
|
|
173
|
-
def test_010_get_shells_submodels_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
174
|
-
result = client.get_shells_submodels_by_id(shared_aas.id, shared_sm.id)
|
|
175
|
-
|
|
176
|
-
assert result is not None
|
|
177
|
-
result_id_short = result.get("idShort", "")
|
|
178
|
-
assert result_id_short == shared_sm.id_short
|
|
179
|
-
|
|
180
|
-
def test_011a_get_submodels_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
181
|
-
result = client.get_submodels_by_id(shared_sm.id)
|
|
182
|
-
|
|
183
|
-
assert result is not None
|
|
184
|
-
result_id_short = result.get("idShort", "")
|
|
185
|
-
assert result_id_short == shared_sm.id_short
|
|
186
|
-
|
|
187
|
-
def test_011b_get_submodels_by_id_not_found(client: AasHttpClient):
|
|
188
|
-
result = client.get_submodels_by_id("non_existent_id")
|
|
189
|
-
|
|
190
|
-
assert result is None
|
|
191
|
-
|
|
192
|
-
def test_012_patch_submodel_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
193
|
-
sm = Submodel(shared_sm.id_short)
|
|
194
|
-
sm.id_short = shared_sm.id_short
|
|
195
|
-
|
|
196
|
-
description_text = "Patched description for unit tests"
|
|
197
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
198
|
-
|
|
199
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
200
|
-
sm_data = json.loads(sm_data_string)
|
|
201
|
-
|
|
202
|
-
result = client.patch_submodel_by_id(shared_sm.id, sm_data)
|
|
203
|
-
|
|
204
|
-
assert result
|
|
205
|
-
|
|
206
|
-
get_result = client.get_submodels_by_id(shared_sm.id)
|
|
207
|
-
assert get_result is not None
|
|
208
|
-
assert get_result.get("idShort", "") == shared_sm.id_short
|
|
209
|
-
assert get_result.get("id", "") == shared_sm.id
|
|
210
|
-
# Only the description may change in patch.
|
|
211
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
212
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_sm.description.get("en", "")
|
|
213
|
-
# The display name must remain the same.
|
|
214
|
-
assert get_result.get("displayName", {})[0].get("text", "") == shared_sm.display_name.get("en", "")
|
|
215
|
-
|
|
216
|
-
def test_013_put_shells_submodels_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
217
|
-
sm = Submodel(shared_sm.id_short)
|
|
218
|
-
sm.id_short = shared_sm.id_short
|
|
219
|
-
|
|
220
|
-
description_text = "Put via shell description for unit tests"
|
|
221
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
222
|
-
|
|
223
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
224
|
-
sm_data = json.loads(sm_data_string)
|
|
225
|
-
|
|
226
|
-
result = client.put_shells_submodels_by_id(shared_aas.id, shared_sm.id, sm_data)
|
|
227
|
-
|
|
228
|
-
assert result
|
|
229
|
-
|
|
230
|
-
get_result = client.get_shells_submodels_by_id(shared_aas.id, shared_sm.id)
|
|
231
|
-
assert get_result is not None
|
|
232
|
-
assert get_result.get("idShort", "") == shared_sm.id_short
|
|
233
|
-
assert get_result.get("id", "") == shared_sm.id
|
|
234
|
-
# description must have changed
|
|
235
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
236
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_sm.description.get("en", "")
|
|
237
|
-
assert len(get_result.get("displayName", {})) == 0
|
|
238
|
-
|
|
239
|
-
# restore to its original state
|
|
240
|
-
sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
241
|
-
sm_data = json.loads(sm_data_string)
|
|
242
|
-
client.put_shells_submodels_by_id(shared_aas.id, shared_sm.id, sm_data) # Restore original submodel
|
|
243
|
-
|
|
244
|
-
def test_014_put_submodels_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
245
|
-
sm = Submodel(shared_sm.id_short)
|
|
246
|
-
sm.id_short = shared_sm.id_short
|
|
247
|
-
|
|
248
|
-
description_text = "Put description for unit tests"
|
|
249
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
250
|
-
|
|
251
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
252
|
-
sm_data = json.loads(sm_data_string)
|
|
253
|
-
|
|
254
|
-
result = client.put_submodels_by_id(shared_sm.id, sm_data)
|
|
255
|
-
|
|
256
|
-
assert result
|
|
257
|
-
|
|
258
|
-
get_result = client.get_submodels_by_id(shared_sm.id)
|
|
259
|
-
assert get_result is not None
|
|
260
|
-
assert get_result.get("idShort", "") == shared_sm.id_short
|
|
261
|
-
assert get_result.get("id", "") == shared_sm.id
|
|
262
|
-
# description must have changed
|
|
263
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
264
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_sm.description.get("en", "")
|
|
265
|
-
assert len(get_result.get("displayName", {})) == 0
|
|
266
|
-
|
|
267
|
-
# restore to its original state
|
|
268
|
-
sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
269
|
-
sm_data = json.loads(sm_data_string)
|
|
270
|
-
client.put_submodels_by_id(shared_sm.id, sm_data) # Restore original submodel
|
|
271
|
-
|
|
272
|
-
def test_098_delete_shells_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
273
|
-
result = client.delete_shells_by_id(shared_aas.id)
|
|
274
|
-
|
|
275
|
-
assert result
|
|
276
|
-
|
|
277
|
-
get_result = client.get_shells()
|
|
278
|
-
assert get_result is not None
|
|
279
|
-
shells = get_result.get("result", [])
|
|
280
|
-
assert len(shells) == 0
|
|
281
|
-
|
|
282
|
-
def test_099_delete_submodel_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
283
|
-
result = client.delete_submodels_by_id(shared_sm.id)
|
|
284
|
-
|
|
285
|
-
assert result
|
|
286
|
-
|
|
287
|
-
get_result = client.get_submodels()
|
|
288
|
-
assert get_result is not None
|
|
289
|
-
submodels = get_result.get("result", [])
|
|
290
|
-
assert len(submodels) == 0
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from aas_http_client.client import create_client_by_config, AasHttpClient
|
|
4
|
-
from basyx.aas.model import AssetAdministrationShell, Submodel, MultiLanguageTextType
|
|
5
|
-
import aas_http_client.utilities.model_builder as model_builder
|
|
6
|
-
import json
|
|
7
|
-
import basyx.aas.adapter.json
|
|
8
|
-
|
|
9
|
-
@pytest.fixture(scope="module")
|
|
10
|
-
def client() -> AasHttpClient:
|
|
11
|
-
try:
|
|
12
|
-
file = Path("./tests/server_configs/test_java_server_config.json").resolve()
|
|
13
|
-
|
|
14
|
-
if not file.exists():
|
|
15
|
-
raise FileNotFoundError(f"Configuration file {file} does not exist.")
|
|
16
|
-
|
|
17
|
-
client = create_client_by_config(file, password="")
|
|
18
|
-
except Exception as e:
|
|
19
|
-
raise RuntimeError("Unable to connect to server.")
|
|
20
|
-
|
|
21
|
-
shells = client.get_shells()
|
|
22
|
-
if shells is None:
|
|
23
|
-
raise RuntimeError("No shells found on server. Please check the server configuration.")
|
|
24
|
-
|
|
25
|
-
for shell in shells.get("result", []):
|
|
26
|
-
id = shell.get("id", "")
|
|
27
|
-
client.delete_shells_by_id(id)
|
|
28
|
-
|
|
29
|
-
submodels = client.get_submodels()
|
|
30
|
-
if submodels is None:
|
|
31
|
-
raise RuntimeError("No submodels found on server. Please check the server configuration.")
|
|
32
|
-
|
|
33
|
-
for submodel in submodels.get("result", []):
|
|
34
|
-
id = submodel.get("id", "")
|
|
35
|
-
client.delete_submodels_by_id(id)
|
|
36
|
-
|
|
37
|
-
return client
|
|
38
|
-
|
|
39
|
-
@pytest.fixture(scope="module")
|
|
40
|
-
def shared_sm() -> Submodel:
|
|
41
|
-
# create a Submodel
|
|
42
|
-
return model_builder.create_base_submodel("sm_http_client_unit_tests", "")
|
|
43
|
-
|
|
44
|
-
@pytest.fixture(scope="module")
|
|
45
|
-
def shared_aas(client: AasHttpClient, shared_sm: Submodel) -> AssetAdministrationShell:
|
|
46
|
-
# create an AAS
|
|
47
|
-
aas = model_builder.create_base_ass(id_short="aas_http_client_unit_tests", namespace="")
|
|
48
|
-
|
|
49
|
-
# add Submodel to AAS
|
|
50
|
-
model_builder.add_submodel_to_aas(aas, shared_sm)
|
|
51
|
-
|
|
52
|
-
return aas
|
|
53
|
-
|
|
54
|
-
def test_001_connect(client: AasHttpClient):
|
|
55
|
-
assert client is not None
|
|
56
|
-
|
|
57
|
-
def test_002_get_shells(client: AasHttpClient):
|
|
58
|
-
result = client.get_shells()
|
|
59
|
-
assert result is not None
|
|
60
|
-
shells = result.get("result", [])
|
|
61
|
-
assert len(shells) == 0
|
|
62
|
-
|
|
63
|
-
def test_003_post_shells(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
64
|
-
aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
65
|
-
aas_data = json.loads(aas_data_string)
|
|
66
|
-
result = client.post_shells(aas_data)
|
|
67
|
-
|
|
68
|
-
assert result is not None
|
|
69
|
-
result_id_short = result.get("idShort", "")
|
|
70
|
-
assert result_id_short == shared_aas.id_short
|
|
71
|
-
|
|
72
|
-
get_result = client.get_shells()
|
|
73
|
-
assert get_result is not None
|
|
74
|
-
shells = get_result.get("result", [])
|
|
75
|
-
assert len(shells) == 1
|
|
76
|
-
assert shells[0].get("idShort", "") == shared_aas.id_short
|
|
77
|
-
|
|
78
|
-
def test_004a_get_shell_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
79
|
-
result = client.get_shells_by_id(shared_aas.id)
|
|
80
|
-
|
|
81
|
-
assert result is not None
|
|
82
|
-
assert result.get("idShort", "") == shared_aas.id_short
|
|
83
|
-
|
|
84
|
-
def test_004b_get_shell_by_id_not_found(client: AasHttpClient):
|
|
85
|
-
result = client.get_shells_by_id("non_existent_id")
|
|
86
|
-
|
|
87
|
-
assert result is None
|
|
88
|
-
|
|
89
|
-
def test_005a_put_shells(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
90
|
-
aas = AssetAdministrationShell(id_=shared_aas.asset_information.global_asset_id, asset_information=shared_aas.asset_information)
|
|
91
|
-
aas.id_short = shared_aas.id_short
|
|
92
|
-
|
|
93
|
-
description_text = "Put description for unit tests"
|
|
94
|
-
aas.description = MultiLanguageTextType({"en": description_text})
|
|
95
|
-
aas.submodel = shared_aas.submodel # Keep existing submodels
|
|
96
|
-
|
|
97
|
-
aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
98
|
-
aas_data = json.loads(aas_data_string)
|
|
99
|
-
|
|
100
|
-
result = client.put_shells(shared_aas.id, aas_data)
|
|
101
|
-
|
|
102
|
-
assert result
|
|
103
|
-
|
|
104
|
-
get_result = client.get_shells_by_id(shared_aas.id)
|
|
105
|
-
|
|
106
|
-
assert get_result is not None
|
|
107
|
-
assert get_result.get("idShort", "") == shared_aas.id_short
|
|
108
|
-
assert get_result.get("id", "") == shared_aas.id
|
|
109
|
-
# description must have changed
|
|
110
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
111
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_aas.description.get("en", "")
|
|
112
|
-
# submodels must be retained
|
|
113
|
-
assert len(get_result.get("submodels", [])) == len(shared_aas.submodel)
|
|
114
|
-
# The display name must be empty
|
|
115
|
-
assert len(get_result.get("displayName", {})) == 0
|
|
116
|
-
|
|
117
|
-
def test_005b_put_shells_with_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
118
|
-
# put with other ID
|
|
119
|
-
id_short = "put_short_id"
|
|
120
|
-
asset_info = model_builder.create_base_asset_information(id_short)
|
|
121
|
-
aas = AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
|
|
122
|
-
aas.id_short = id_short
|
|
123
|
-
|
|
124
|
-
description_text = {"en": "Updated description for unit tests"}
|
|
125
|
-
aas.description = MultiLanguageTextType(description_text)
|
|
126
|
-
|
|
127
|
-
aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
128
|
-
aas_data = json.loads(aas_data_string)
|
|
129
|
-
|
|
130
|
-
aas_data["id"] = "updated_id" # Ensure the id is included in the update
|
|
131
|
-
|
|
132
|
-
result = client.put_shells(shared_aas.id, aas_data)
|
|
133
|
-
|
|
134
|
-
assert not result
|
|
135
|
-
|
|
136
|
-
def test_006_get_shells_reference_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
137
|
-
result = client.get_shells_reference_by_id(shared_aas.id)
|
|
138
|
-
|
|
139
|
-
# Basyx java server do not provide this endpoint
|
|
140
|
-
assert not result
|
|
141
|
-
|
|
142
|
-
def test_007_get_shells_submodels_by_id_not_posted(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
143
|
-
result = client.get_shells_submodels_by_id(shared_aas.id, shared_sm.id)
|
|
144
|
-
|
|
145
|
-
assert result is None
|
|
146
|
-
|
|
147
|
-
def test_008_get_submodels(client: AasHttpClient):
|
|
148
|
-
result = client.get_submodels()
|
|
149
|
-
|
|
150
|
-
assert result
|
|
151
|
-
submodels = result.get("result", [])
|
|
152
|
-
assert len(submodels) == 0
|
|
153
|
-
|
|
154
|
-
def test_009_post_submodels(client: AasHttpClient, shared_sm: Submodel):
|
|
155
|
-
sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
156
|
-
sm_data = json.loads(sm_data_string)
|
|
157
|
-
|
|
158
|
-
result = client.post_submodels(sm_data)
|
|
159
|
-
|
|
160
|
-
assert result is not None
|
|
161
|
-
result_id_short = result.get("idShort", "")
|
|
162
|
-
assert result_id_short == shared_sm.id_short
|
|
163
|
-
|
|
164
|
-
get_result = client.get_submodels()
|
|
165
|
-
assert get_result is not None
|
|
166
|
-
submodels = get_result.get("result", [])
|
|
167
|
-
assert len(submodels) == 1
|
|
168
|
-
assert submodels[0].get("idShort", "") == shared_sm.id_short
|
|
169
|
-
|
|
170
|
-
def test_010_get_shells_submodels_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
171
|
-
result = client.get_shells_submodels_by_id(shared_aas.id, shared_sm.id)
|
|
172
|
-
|
|
173
|
-
# Basyx java server do not provide this endpoint
|
|
174
|
-
assert result is None
|
|
175
|
-
|
|
176
|
-
def test_011a_get_submodels_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
177
|
-
result = client.get_submodels_by_id(shared_sm.id)
|
|
178
|
-
|
|
179
|
-
assert result is not None
|
|
180
|
-
result_id_short = result.get("idShort", "")
|
|
181
|
-
assert result_id_short == shared_sm.id_short
|
|
182
|
-
|
|
183
|
-
def test_011b_get_submodels_by_id_not_found(client: AasHttpClient):
|
|
184
|
-
result = client.get_submodels_by_id("non_existent_id")
|
|
185
|
-
|
|
186
|
-
assert result is None
|
|
187
|
-
|
|
188
|
-
def test_012_patch_submodel_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
189
|
-
sm = Submodel(shared_sm.id_short)
|
|
190
|
-
sm.id_short = shared_sm.id_short
|
|
191
|
-
|
|
192
|
-
description_text = "Patched description for unit tests"
|
|
193
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
194
|
-
|
|
195
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
196
|
-
sm_data = json.loads(sm_data_string)
|
|
197
|
-
|
|
198
|
-
result = client.patch_submodel_by_id(shared_sm.id, sm_data)
|
|
199
|
-
|
|
200
|
-
# Basyx java server do not provide this endpoint
|
|
201
|
-
assert not result
|
|
202
|
-
|
|
203
|
-
def test_013_put_shells_submodels_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell, shared_sm: Submodel):
|
|
204
|
-
sm = Submodel(shared_sm.id_short)
|
|
205
|
-
sm.id_short = shared_sm.id_short
|
|
206
|
-
|
|
207
|
-
description_text = "Put via shell description for unit tests"
|
|
208
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
209
|
-
|
|
210
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
211
|
-
sm_data = json.loads(sm_data_string)
|
|
212
|
-
|
|
213
|
-
result = client.put_shells_submodels_by_id(shared_aas.id, shared_sm.id, sm_data)
|
|
214
|
-
|
|
215
|
-
assert not result
|
|
216
|
-
|
|
217
|
-
def test_014_put_submodels_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
218
|
-
sm = Submodel(shared_sm.id_short)
|
|
219
|
-
sm.id_short = shared_sm.id_short
|
|
220
|
-
|
|
221
|
-
description_text = "Put description for unit tests"
|
|
222
|
-
sm.description = MultiLanguageTextType({"en": description_text})
|
|
223
|
-
|
|
224
|
-
sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
225
|
-
sm_data = json.loads(sm_data_string)
|
|
226
|
-
|
|
227
|
-
result = client.put_submodels_by_id(shared_sm.id, sm_data)
|
|
228
|
-
|
|
229
|
-
assert result
|
|
230
|
-
|
|
231
|
-
get_result = client.get_submodels_by_id(shared_sm.id)
|
|
232
|
-
assert get_result is not None
|
|
233
|
-
assert get_result.get("idShort", "") == shared_sm.id_short
|
|
234
|
-
assert get_result.get("id", "") == shared_sm.id
|
|
235
|
-
# description must have changed
|
|
236
|
-
assert get_result.get("description", {})[0].get("text", "") == description_text
|
|
237
|
-
assert get_result.get("description", {})[0].get("text", "") != shared_sm.description.get("en", "")
|
|
238
|
-
assert len(get_result.get("displayName", {})) == 0
|
|
239
|
-
|
|
240
|
-
# restore to its original state
|
|
241
|
-
sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
242
|
-
sm_data = json.loads(sm_data_string)
|
|
243
|
-
client.put_submodels_by_id(shared_sm.id, sm_data) # Restore original submodel
|
|
244
|
-
|
|
245
|
-
def test_098_delete_shells_by_id(client: AasHttpClient, shared_aas: AssetAdministrationShell):
|
|
246
|
-
result = client.delete_shells_by_id(shared_aas.id)
|
|
247
|
-
|
|
248
|
-
assert result
|
|
249
|
-
|
|
250
|
-
get_result = client.get_shells()
|
|
251
|
-
assert get_result is not None
|
|
252
|
-
shells = get_result.get("result", [])
|
|
253
|
-
assert len(shells) == 0
|
|
254
|
-
|
|
255
|
-
def test_099_delete_submodel_by_id(client: AasHttpClient, shared_sm: Submodel):
|
|
256
|
-
result = client.delete_submodels_by_id(shared_sm.id)
|
|
257
|
-
|
|
258
|
-
assert result
|
|
259
|
-
|
|
260
|
-
get_result = client.get_submodels()
|
|
261
|
-
assert get_result is not None
|
|
262
|
-
submodels = get_result.get("result", [])
|
|
263
|
-
assert len(submodels) == 0
|
|
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
|
|
File without changes
|
{aas_http_client-0.1.9 → aas_http_client-0.1.92}/aas_http_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|