aas-http-client 0.3.6__tar.gz → 0.3.9__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.3.6 → aas_http_client-0.3.9}/PKG-INFO +1 -1
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/client.py +6 -6
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/core/version_check.py +4 -2
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/demo/demo_process.py +1 -1
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/utilities/model_builder.py +8 -21
- aas_http_client-0.3.9/aas_http_client/utilities/sdk_tools.py +50 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/wrapper/sdk_wrapper.py +5 -30
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/PKG-INFO +1 -1
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/SOURCES.txt +1 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/pyproject.toml +1 -1
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/tests/test_client.py +16 -12
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/tests/test_wrapper.py +12 -10
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/LICENSE +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/README.md +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/__init__.py +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/core/encoder.py +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client/utilities/__init__.py +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/dependency_links.txt +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/requires.txt +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/top_level.txt +0 -0
- {aas_http_client-0.3.6 → aas_http_client-0.3.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: Generic python HTTP client for communication 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
|
|
@@ -617,7 +617,7 @@ def create_client_by_url(
|
|
|
617
617
|
:param trust_env: Whether to trust environment variables for proxy settings, defaults to True
|
|
618
618
|
:return: An instance of Http client initialized with the provided parameters.
|
|
619
619
|
"""
|
|
620
|
-
logger.info(f"Create AAS server http client from URL '{base_url}'")
|
|
620
|
+
logger.info(f"Create AAS server http client from URL '{base_url}'.")
|
|
621
621
|
config_dict: dict[str, str] = {}
|
|
622
622
|
config_dict["base_url"] = base_url
|
|
623
623
|
config_dict["username"] = username
|
|
@@ -637,7 +637,7 @@ def create_client_by_dict(configuration: dict, password: str = "") -> AasHttpCli
|
|
|
637
637
|
:param password: Password for the AAS server, defaults to ""_
|
|
638
638
|
:return: An instance of Http client initialized with the provided parameters.
|
|
639
639
|
"""
|
|
640
|
-
logger.info(
|
|
640
|
+
logger.info("Create AAS server http client from dictionary.")
|
|
641
641
|
config_string = json.dumps(configuration, indent=4)
|
|
642
642
|
|
|
643
643
|
return _create_client(config_string, password)
|
|
@@ -651,7 +651,7 @@ def create_client_by_config(config_file: Path, password: str = "") -> AasHttpCli
|
|
|
651
651
|
:return: An instance of Http client initialized with the provided parameters.
|
|
652
652
|
"""
|
|
653
653
|
config_file = config_file.resolve()
|
|
654
|
-
logger.info(f"Create AAS server http client from configuration file '{config_file}'")
|
|
654
|
+
logger.info(f"Create AAS server http client from configuration file '{config_file}'.")
|
|
655
655
|
if not config_file.exists():
|
|
656
656
|
config_string = "{}"
|
|
657
657
|
logger.warning(f"Configuration file '{config_file}' not found. Using default configuration.")
|
|
@@ -674,7 +674,7 @@ def _create_client(config_string: str, password: str) -> AasHttpClient | None:
|
|
|
674
674
|
f"username: '{client.username}' | "
|
|
675
675
|
f"https_proxy: '{client.https_proxy}' | "
|
|
676
676
|
f"http_proxy: '{client.http_proxy}' | "
|
|
677
|
-
f"connection_timeout: '{client.connection_time_out}'"
|
|
677
|
+
f"connection_timeout: '{client.connection_time_out}'."
|
|
678
678
|
)
|
|
679
679
|
client.initialize(password)
|
|
680
680
|
|
|
@@ -689,7 +689,7 @@ def _create_client(config_string: str, password: str) -> AasHttpClient | None:
|
|
|
689
689
|
|
|
690
690
|
def _connect_to_api(client: AasHttpClient) -> bool:
|
|
691
691
|
start_time = time.time()
|
|
692
|
-
logger.debug(f"Try to connect to REST API '{client.base_url}' for {client.connection_time_out} seconds")
|
|
692
|
+
logger.debug(f"Try to connect to REST API '{client.base_url}' for {client.connection_time_out} seconds.")
|
|
693
693
|
counter: int = 0
|
|
694
694
|
while True:
|
|
695
695
|
try:
|
|
@@ -703,7 +703,7 @@ def _connect_to_api(client: AasHttpClient) -> bool:
|
|
|
703
703
|
raise TimeoutError(f"Connection to server API timed out after {client.connection_time_out} seconds.")
|
|
704
704
|
|
|
705
705
|
counter += 1
|
|
706
|
-
logger.warning(f"Retrying connection (attempt: {counter})")
|
|
706
|
+
logger.warning(f"Retrying connection (attempt: {counter}).")
|
|
707
707
|
time.sleep(1)
|
|
708
708
|
|
|
709
709
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import requests
|
|
2
1
|
import importlib.metadata
|
|
3
2
|
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
|
|
4
6
|
def check_for_update(package_name="aas-http-client"):
|
|
5
7
|
try:
|
|
6
8
|
current_version = importlib.metadata.version(package_name)
|
|
@@ -14,4 +16,4 @@ def check_for_update(package_name="aas-http-client"):
|
|
|
14
16
|
f"Use the following command to update the package: pip install --upgrade {package_name}"
|
|
15
17
|
)
|
|
16
18
|
except Exception:
|
|
17
|
-
pass
|
|
19
|
+
pass
|
|
@@ -16,7 +16,7 @@ def start() -> None:
|
|
|
16
16
|
"""Start the demo process."""
|
|
17
17
|
# create a submodel element
|
|
18
18
|
sme_short_id: str = model_builder.create_unique_short_id("poc_sme")
|
|
19
|
-
sme = model_builder.
|
|
19
|
+
sme = model_builder.create_base_submodel_element_property(sme_short_id, model.datatypes.String, "Sample Value")
|
|
20
20
|
|
|
21
21
|
# create a submodel
|
|
22
22
|
sm_short_id: str = model_builder.create_unique_short_id("poc_sm")
|
|
@@ -18,10 +18,10 @@ def create_unique_short_id(id_short: str) -> str:
|
|
|
18
18
|
return f"{id_short}_{str(uuid.uuid4()).replace('-', '_')}"
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def
|
|
21
|
+
def create_base_submodel_element_property(
|
|
22
22
|
id_short: str, type: model.datatypes, value: Any, display_name: str = "", description: str = ""
|
|
23
23
|
) -> model.Property:
|
|
24
|
-
"""Create a basic
|
|
24
|
+
"""Create a basic SubmodelElement of type Property."""
|
|
25
25
|
sme = model.Property(id_short=id_short, value_type=type, value=value)
|
|
26
26
|
|
|
27
27
|
if not description:
|
|
@@ -39,17 +39,15 @@ def create_base_submodel_element_Property(
|
|
|
39
39
|
return sme
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def create_base_submodel(
|
|
42
|
+
def create_base_submodel(identifier: str, id_short: str, display_name: str = "", description: str = "") -> model.Submodel:
|
|
43
43
|
"""Create a basic Submodel.
|
|
44
44
|
|
|
45
|
+
:param identifier: identifier of the Submodel
|
|
45
46
|
:param id_short: ID short of the Submodel
|
|
46
|
-
:param namespace: namespace of the Submodel , defaults to "fluid40"
|
|
47
47
|
:param display_name: display name of the Submodel, defaults to ""
|
|
48
48
|
:param description: description of the Submodel, defaults to ""
|
|
49
49
|
:return: Submodel instance
|
|
50
50
|
"""
|
|
51
|
-
identifier = f"{namespace}/{id_short}" if namespace else id_short
|
|
52
|
-
|
|
53
51
|
sm = model.Submodel(identifier)
|
|
54
52
|
sm.id_short = id_short
|
|
55
53
|
|
|
@@ -68,16 +66,16 @@ def create_base_submodel(id_short: str, namespace: str = "fluid40", display_name
|
|
|
68
66
|
return sm
|
|
69
67
|
|
|
70
68
|
|
|
71
|
-
def create_base_ass(
|
|
69
|
+
def create_base_ass(identifier: str, id_short: str, display_name: str = "", description: str = "") -> model.AssetAdministrationShell:
|
|
72
70
|
"""Create a basic AAS.
|
|
73
71
|
|
|
72
|
+
:param identifier: identifier of the AAS
|
|
74
73
|
:param id_short: ID short of the AAS
|
|
75
|
-
:param namespace: namespace of the AAS, defaults to "basyx_python_aas_server"
|
|
76
74
|
:param display_name: display name of the AAS, defaults to ""
|
|
77
75
|
:param description: description of the AAS, defaults to ""
|
|
78
76
|
:return: AssetAdministrationShell instance
|
|
79
77
|
"""
|
|
80
|
-
asset_info = create_base_asset_information(
|
|
78
|
+
asset_info = create_base_asset_information(identifier)
|
|
81
79
|
|
|
82
80
|
aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
|
|
83
81
|
aas.id_short = id_short
|
|
@@ -97,24 +95,13 @@ def create_base_ass(id_short: str, namespace: str = "fluid40", display_name: str
|
|
|
97
95
|
return aas
|
|
98
96
|
|
|
99
97
|
|
|
100
|
-
def
|
|
101
|
-
"""Add a given Submodel correctly to a provided AssetAdministrationShell.
|
|
102
|
-
|
|
103
|
-
:param aas: provided AssetAdministrationShell to which the Submodel should be added
|
|
104
|
-
:param submodel: given Submodel to add
|
|
105
|
-
"""
|
|
106
|
-
# aas.submodel.add(submodel)
|
|
107
|
-
aas.submodel.add(model.ModelReference.from_referable(submodel))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def create_base_asset_information(id_short: str, namespace: str = "basyx_python_aas_server") -> model.AssetInformation:
|
|
98
|
+
def create_base_asset_information(identifier: str) -> model.AssetInformation:
|
|
111
99
|
"""Return a basic AssetInformation instance.
|
|
112
100
|
|
|
113
101
|
:param id_short: short ID of the AssetInformation
|
|
114
102
|
:param namespace: namespace of the AssetInformation, defaults to "basyx_python_aas_server"
|
|
115
103
|
:return: AssetInformation instance
|
|
116
104
|
"""
|
|
117
|
-
identifier = f"{namespace}/{id_short}" if namespace else id_short
|
|
118
105
|
return model.AssetInformation(model.AssetKind.INSTANCE, identifier)
|
|
119
106
|
|
|
120
107
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Utility functions for working with the BaSyx SDK framework objects."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import basyx.aas.adapter.json
|
|
8
|
+
from basyx.aas import model
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def add_submodel_to_aas(aas: model.AssetAdministrationShell, submodel: model.Submodel) -> None:
|
|
14
|
+
"""Add a given Submodel correctly to a provided AssetAdministrationShell.
|
|
15
|
+
|
|
16
|
+
:param aas: provided AssetAdministrationShell to which the Submodel should be added
|
|
17
|
+
:param submodel: given Submodel to add
|
|
18
|
+
"""
|
|
19
|
+
# aas.submodel.add(submodel)
|
|
20
|
+
aas.submodel.add(model.ModelReference.from_referable(submodel))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def convert_to_object(content: dict) -> Any | None:
|
|
24
|
+
"""Convert a dictionary to a BaSyx SDK framework object.
|
|
25
|
+
|
|
26
|
+
:param content: dictionary to convert
|
|
27
|
+
:return: BaSyx SDK framework object or None
|
|
28
|
+
"""
|
|
29
|
+
try:
|
|
30
|
+
dict_string = json.dumps(content)
|
|
31
|
+
return json.loads(dict_string, cls=basyx.aas.adapter.json.AASFromJsonDecoder)
|
|
32
|
+
except Exception as e:
|
|
33
|
+
logger.error(f"Decoding error: {e}")
|
|
34
|
+
logger.error(f"In JSON: {content}")
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def convert_to_dict(object: Any) -> dict | None:
|
|
39
|
+
"""Convert a BaSyx SDK framework object. to a dictionary.
|
|
40
|
+
|
|
41
|
+
:param object: BaSyx SDK framework object to convert
|
|
42
|
+
:return: dictionary representation of the object or None
|
|
43
|
+
"""
|
|
44
|
+
try:
|
|
45
|
+
data_string = json.dumps(object, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
46
|
+
return json.loads(data_string)
|
|
47
|
+
except Exception as e:
|
|
48
|
+
logger.error(f"Encoding error: {e}")
|
|
49
|
+
logger.error(f"In object: {object}")
|
|
50
|
+
return None
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Any
|
|
7
6
|
|
|
8
|
-
import basyx.aas.adapter.json
|
|
9
7
|
from basyx.aas import model
|
|
10
8
|
|
|
11
9
|
from aas_http_client.client import AasHttpClient, _create_client
|
|
10
|
+
from aas_http_client.utilities.sdk_tools import convert_to_dict as _to_dict
|
|
11
|
+
from aas_http_client.utilities.sdk_tools import convert_to_object as _to_object
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger(__name__)
|
|
14
14
|
|
|
@@ -298,31 +298,6 @@ class SdkWrapper:
|
|
|
298
298
|
return self._client
|
|
299
299
|
|
|
300
300
|
|
|
301
|
-
# region utils
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
def _to_object(content: dict) -> Any | None:
|
|
305
|
-
try:
|
|
306
|
-
dict_string = json.dumps(content)
|
|
307
|
-
return json.loads(dict_string, cls=basyx.aas.adapter.json.AASFromJsonDecoder)
|
|
308
|
-
except Exception as e:
|
|
309
|
-
logger.error(f"Decoding error: {e}")
|
|
310
|
-
logger.error(f"In JSON: {content}")
|
|
311
|
-
return None
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def _to_dict(object: Any) -> dict | None:
|
|
315
|
-
try:
|
|
316
|
-
data_string = json.dumps(object, cls=basyx.aas.adapter.json.AASToJsonEncoder)
|
|
317
|
-
return json.loads(data_string)
|
|
318
|
-
except Exception as e:
|
|
319
|
-
logger.error(f"Encoding error: {e}")
|
|
320
|
-
logger.error(f"In object: {object}")
|
|
321
|
-
return None
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
# endregion
|
|
325
|
-
|
|
326
301
|
# region wrapper
|
|
327
302
|
|
|
328
303
|
|
|
@@ -350,7 +325,7 @@ def create_wrapper_by_url(
|
|
|
350
325
|
:param trust_env: Whether to trust environment variables for proxy settings, defaults to True
|
|
351
326
|
:return: An instance of SdkWrapper initialized with the provided parameters.
|
|
352
327
|
"""
|
|
353
|
-
logger.info(f"Create AAS server wrapper from URL '{base_url}'")
|
|
328
|
+
logger.info(f"Create AAS server wrapper from URL '{base_url}'.")
|
|
354
329
|
config_dict: dict[str, str] = {}
|
|
355
330
|
config_dict["base_url"] = base_url
|
|
356
331
|
config_dict["username"] = username
|
|
@@ -370,7 +345,7 @@ def create_wrapper_by_dict(configuration: dict, password: str = "") -> SdkWrappe
|
|
|
370
345
|
:param password: Password for the BaSyx server interface client, defaults to "".
|
|
371
346
|
:return: An instance of SdkWrapper initialized with the provided parameters.
|
|
372
347
|
"""
|
|
373
|
-
logger.info(
|
|
348
|
+
logger.info("Create AAS server wrapper from dictionary.")
|
|
374
349
|
config_string = json.dumps(configuration, indent=4)
|
|
375
350
|
return SdkWrapper(config_string, password)
|
|
376
351
|
|
|
@@ -382,7 +357,7 @@ def create_wrapper_by_config(config_file: Path, password: str = "") -> SdkWrappe
|
|
|
382
357
|
:param password: password for the BaSyx server interface client, defaults to ""_
|
|
383
358
|
:return: An instance of SdkWrapper initialized with the provided parameters.
|
|
384
359
|
"""
|
|
385
|
-
logger.info(f"Create AAS wrapper client from configuration file '{config_file}'")
|
|
360
|
+
logger.info(f"Create AAS wrapper client from configuration file '{config_file}'.")
|
|
386
361
|
if not config_file.exists():
|
|
387
362
|
config_string = "{}"
|
|
388
363
|
logger.warning(f"Configuration file '{config_file}' not found. Using default config.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: Generic python HTTP client for communication 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
|
|
@@ -13,6 +13,7 @@ aas_http_client/core/version_check.py
|
|
|
13
13
|
aas_http_client/demo/demo_process.py
|
|
14
14
|
aas_http_client/utilities/__init__.py
|
|
15
15
|
aas_http_client/utilities/model_builder.py
|
|
16
|
+
aas_http_client/utilities/sdk_tools.py
|
|
16
17
|
aas_http_client/wrapper/sdk_wrapper.py
|
|
17
18
|
tests/test_client.py
|
|
18
19
|
tests/test_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.3.
|
|
7
|
+
version = "0.3.9"
|
|
8
8
|
description = "Generic python HTTP client for communication with various types of AAS servers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
from aas_http_client.client import create_client_by_config, AasHttpClient, create_client_by_dict, create_client_by_url
|
|
4
4
|
from basyx.aas import model
|
|
5
5
|
import aas_http_client.utilities.model_builder as model_builder
|
|
6
|
+
import aas_http_client.utilities.sdk_tools as sdk_tools
|
|
6
7
|
import json
|
|
7
8
|
import basyx.aas.adapter.json
|
|
8
9
|
from urllib.parse import urlparse
|
|
@@ -41,35 +42,35 @@ def client(request) -> AasHttpClient:
|
|
|
41
42
|
@pytest.fixture(scope="module")
|
|
42
43
|
def shared_sme_string() -> model.Property:
|
|
43
44
|
# create a Submodel
|
|
44
|
-
return model_builder.
|
|
45
|
+
return model_builder.create_base_submodel_element_property("sme_property_string", model.datatypes.String, "Sample String Value")
|
|
45
46
|
|
|
46
47
|
@pytest.fixture(scope="module")
|
|
47
48
|
def shared_sme_bool() -> model.Property:
|
|
48
49
|
# create a Submodel
|
|
49
|
-
return model_builder.
|
|
50
|
+
return model_builder.create_base_submodel_element_property("sme_property_bool", model.datatypes.Boolean, True)
|
|
50
51
|
|
|
51
52
|
@pytest.fixture(scope="module")
|
|
52
53
|
def shared_sme_int() -> model.Property:
|
|
53
54
|
# create a Submodel
|
|
54
|
-
return model_builder.
|
|
55
|
+
return model_builder.create_base_submodel_element_property("sme_property_int", model.datatypes.Integer, 262)
|
|
55
56
|
|
|
56
57
|
@pytest.fixture(scope="module")
|
|
57
58
|
def shared_sme_float() -> model.Property:
|
|
58
59
|
# create a Submodel
|
|
59
|
-
return model_builder.
|
|
60
|
+
return model_builder.create_base_submodel_element_property("sme_property_float", model.datatypes.Float, 262.3)
|
|
60
61
|
|
|
61
62
|
@pytest.fixture(scope="module")
|
|
62
63
|
def shared_sm() -> model.Submodel:
|
|
63
64
|
# create a Submodel
|
|
64
|
-
return model_builder.create_base_submodel("sm_http_client_unit_tests", "")
|
|
65
|
+
return model_builder.create_base_submodel(identifier="fluid40/sm_http_client_unit_tests", id_short="sm_http_client_unit_tests")
|
|
65
66
|
|
|
66
67
|
@pytest.fixture(scope="module")
|
|
67
68
|
def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
|
|
68
69
|
# create an AAS
|
|
69
|
-
aas = model_builder.create_base_ass(
|
|
70
|
+
aas = model_builder.create_base_ass(identifier="fluid40/aas_http_client_unit_tests", id_short="aas_http_client_unit_tests")
|
|
70
71
|
|
|
71
72
|
# add Submodel to AAS
|
|
72
|
-
|
|
73
|
+
sdk_tools.add_submodel_to_aas(aas, shared_sm)
|
|
73
74
|
|
|
74
75
|
return aas
|
|
75
76
|
|
|
@@ -133,20 +134,22 @@ def test_003_post_asset_administration_shell(client: AasHttpClient, shared_aas:
|
|
|
133
134
|
result = client.post_asset_administration_shell(aas_data)
|
|
134
135
|
|
|
135
136
|
assert result is not None
|
|
136
|
-
|
|
137
|
-
assert
|
|
137
|
+
assert result.get("idShort", "") == shared_aas.id_short
|
|
138
|
+
assert result.get("id", "") == shared_aas.id
|
|
138
139
|
|
|
139
140
|
get_result = client.get_all_asset_administration_shells()
|
|
140
141
|
assert get_result is not None
|
|
141
142
|
shells = get_result.get("result", [])
|
|
142
143
|
assert len(shells) == 1
|
|
143
144
|
assert shells[0].get("idShort", "") == shared_aas.id_short
|
|
145
|
+
assert shells[0].get("id", "") == shared_aas.id
|
|
144
146
|
|
|
145
147
|
def test_004a_get_asset_administration_shell_by_id(client: AasHttpClient, shared_aas: model.AssetAdministrationShell):
|
|
146
148
|
result = client.get_asset_administration_shell_by_id(shared_aas.id)
|
|
147
149
|
|
|
148
150
|
assert result is not None
|
|
149
151
|
assert result.get("idShort", "") == shared_aas.id_short
|
|
152
|
+
assert result.get("id", "") == shared_aas.id
|
|
150
153
|
|
|
151
154
|
def test_004b_get_asset_administration_shell_by_id(client: AasHttpClient):
|
|
152
155
|
result = client.get_asset_administration_shell_by_id("non_existent_id")
|
|
@@ -191,7 +194,8 @@ def test_005a_put_asset_administration_shell_by_id(client: AasHttpClient, shared
|
|
|
191
194
|
def test_005b_put_asset_administration_shell_by_id(client: AasHttpClient, shared_aas: model.AssetAdministrationShell):
|
|
192
195
|
# put with other ID
|
|
193
196
|
id_short = "put_short_id"
|
|
194
|
-
|
|
197
|
+
identifier = f"fluid40/{id_short}"
|
|
198
|
+
asset_info = model_builder.create_base_asset_information(identifier)
|
|
195
199
|
aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
|
|
196
200
|
aas.id_short = id_short
|
|
197
201
|
|
|
@@ -309,7 +313,7 @@ def test_012_patch_submodel_by_id(client: AasHttpClient, shared_sm: model.Submod
|
|
|
309
313
|
assert get_result.get("displayName", {})[0].get("text", "") == shared_sm.display_name.get("en", "")
|
|
310
314
|
|
|
311
315
|
def test_013_put_submodel_by_id_aas_repository(client: AasHttpClient, shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
312
|
-
sm = model.Submodel(shared_sm.
|
|
316
|
+
sm = model.Submodel(shared_sm.id)
|
|
313
317
|
sm.id_short = shared_sm.id_short
|
|
314
318
|
|
|
315
319
|
description_text = "Put via shell description for unit tests"
|
|
@@ -342,7 +346,7 @@ def test_013_put_submodel_by_id_aas_repository(client: AasHttpClient, shared_aas
|
|
|
342
346
|
client.put_submodel_by_id_aas_repository(shared_aas.id, shared_sm.id, sm_data) # Restore original submodel
|
|
343
347
|
|
|
344
348
|
def test_014_put_submodels_by_id(client: AasHttpClient, shared_sm: model.Submodel):
|
|
345
|
-
sm = model.Submodel(shared_sm.
|
|
349
|
+
sm = model.Submodel(shared_sm.id)
|
|
346
350
|
sm.id_short = shared_sm.id_short
|
|
347
351
|
|
|
348
352
|
description_text = "Put description for unit tests"
|
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
from aas_http_client.wrapper.sdk_wrapper import create_wrapper_by_config, SdkWrapper, create_wrapper_by_dict, create_wrapper_by_url
|
|
4
4
|
from basyx.aas import model
|
|
5
5
|
import aas_http_client.utilities.model_builder as model_builder
|
|
6
|
+
import aas_http_client.utilities.sdk_tools as sdk_tools
|
|
6
7
|
from urllib.parse import urlparse
|
|
7
8
|
import json
|
|
8
9
|
|
|
@@ -41,37 +42,37 @@ def wrapper(request) -> SdkWrapper:
|
|
|
41
42
|
@pytest.fixture(scope="module")
|
|
42
43
|
def shared_sme_string() -> model.Property:
|
|
43
44
|
# create a Submodel
|
|
44
|
-
return model_builder.
|
|
45
|
+
return model_builder.create_base_submodel_element_property("sme_property_string", model.datatypes.String, "Sample String Value")
|
|
45
46
|
|
|
46
47
|
@pytest.fixture(scope="module")
|
|
47
48
|
def shared_sme_bool() -> model.Property:
|
|
48
49
|
# create a Submodel
|
|
49
|
-
return model_builder.
|
|
50
|
+
return model_builder.create_base_submodel_element_property("sme_property_bool", model.datatypes.Boolean, True)
|
|
50
51
|
|
|
51
52
|
@pytest.fixture(scope="module")
|
|
52
53
|
def shared_sme_int() -> model.Property:
|
|
53
54
|
# create a Submodel
|
|
54
|
-
return model_builder.
|
|
55
|
+
return model_builder.create_base_submodel_element_property("sme_property_int", model.datatypes.Integer, 262)
|
|
55
56
|
|
|
56
57
|
@pytest.fixture(scope="module")
|
|
57
58
|
def shared_sme_float() -> model.Property:
|
|
58
59
|
# create a Submodel
|
|
59
|
-
return model_builder.
|
|
60
|
+
return model_builder.create_base_submodel_element_property("sme_property_float", model.datatypes.Float, 262.3)
|
|
60
61
|
|
|
61
62
|
@pytest.fixture(scope="module")
|
|
62
63
|
def shared_sm() -> model.Submodel:
|
|
63
64
|
# create a Submodel
|
|
64
|
-
submodel = model_builder.create_base_submodel("sm_http_client_unit_tests", "")
|
|
65
|
+
submodel = model_builder.create_base_submodel(identifier="fluid40/sm_http_client_unit_tests", id_short="sm_http_client_unit_tests")
|
|
65
66
|
submodel.category = "Unit Test"
|
|
66
67
|
return submodel
|
|
67
68
|
|
|
68
69
|
@pytest.fixture(scope="module")
|
|
69
70
|
def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
|
|
70
71
|
# create an AAS
|
|
71
|
-
aas = model_builder.create_base_ass(
|
|
72
|
+
aas = model_builder.create_base_ass(identifier="fluid40/aas_http_client_unit_tests", id_short="aas_http_client_unit_tests")
|
|
72
73
|
|
|
73
74
|
# add Submodel to AAS
|
|
74
|
-
|
|
75
|
+
sdk_tools.add_submodel_to_aas(aas, shared_sm)
|
|
75
76
|
|
|
76
77
|
return aas
|
|
77
78
|
|
|
@@ -162,7 +163,8 @@ def test_005a_put_asset_administration_shell_by_id(wrapper: SdkWrapper, shared_a
|
|
|
162
163
|
def test_005b_put_asset_administration_shell_by_id(wrapper: SdkWrapper, shared_aas: model.AssetAdministrationShell):
|
|
163
164
|
# put with other ID
|
|
164
165
|
id_short = "put_short_id"
|
|
165
|
-
|
|
166
|
+
identifier = f"fluid40/{id_short}"
|
|
167
|
+
asset_info = model_builder.create_base_asset_information(identifier)
|
|
166
168
|
aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
|
|
167
169
|
aas.id_short = id_short
|
|
168
170
|
|
|
@@ -267,7 +269,7 @@ def test_012_patch_submodel_by_id(wrapper: SdkWrapper, shared_sm: model.Submodel
|
|
|
267
269
|
assert len(submodel.submodel_element) == len(shared_sm.submodel_element)
|
|
268
270
|
|
|
269
271
|
def test_013_put_submodel_by_id_aas_repository(wrapper: SdkWrapper, shared_aas: model.AssetAdministrationShell, shared_sm: model.Submodel):
|
|
270
|
-
sm = model.Submodel(shared_sm.
|
|
272
|
+
sm = model.Submodel(shared_sm.id)
|
|
271
273
|
sm.id_short = shared_sm.id_short
|
|
272
274
|
|
|
273
275
|
description_text = "Put via shell description for unit tests"
|
|
@@ -300,7 +302,7 @@ def test_013_put_submodel_by_id_aas_repository(wrapper: SdkWrapper, shared_aas:
|
|
|
300
302
|
wrapper.put_submodel_by_id_aas_repository(shared_aas.id, shared_sm.id, shared_sm) # Restore original submodel
|
|
301
303
|
|
|
302
304
|
def test_014_put_submodels_by_id(wrapper: SdkWrapper, shared_sm: model.Submodel):
|
|
303
|
-
sm = model.Submodel(shared_sm.
|
|
305
|
+
sm = model.Submodel(shared_sm.id)
|
|
304
306
|
sm.id_short = shared_sm.id_short
|
|
305
307
|
|
|
306
308
|
description_text = "Put description for unit tests"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_http_client-0.3.6 → aas_http_client-0.3.9}/aas_http_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|