1from multiprocessing.sharedctypes
import Value
3from pathlib
import Path
4from aas_http_client.classes.client.aas_client
import create_by_config, AasHttpClient, create_by_dict, create_by_url
5from basyx.aas
import model
9import basyx.aas.adapter.json
10from urllib.parse
import urlparse
12from aas_http_client.demo.logging_handler
import initialize_logging
17logger = logging.getLogger(__name__)
19JAVA_SERVER_PORTS = [8075]
20PYTHON_SERVER_PORTS = [5080, 80]
21DOTNET_SERVER_PORTS = [5043]
23AIMC_SM_ID =
"https://fluid40.de/ids/sm/7644_4034_2556_2369"
24SM_ID =
"fluid40/sm_http_client_unit_tests"
25SHELL_ID =
"fluid40/aas_http_client_unit_tests"
30 "./tests/server_configs/test_java_server_config.json",
31 "./tests/server_configs/test_java_server_alias_config.json",
32 "./tests/server_configs/test_dotnet_server_config.json",
39@pytest.fixture(params=CONFIG_FILES, scope="module")
40def client(request) -> AasHttpClient:
43 file = Path(request.param).resolve()
46 raise FileNotFoundError(f
"Configuration file {file} does not exist.")
48 client = create_by_config(file)
51 raise RuntimeError(
"Failed to create client from configuration file.")
54 rand = random.randint(0, 10)
56 client.encoded_ids =
True
58 except Exception
as e:
59 raise RuntimeError(
"Unable to connect to server.")
62 if client.shells
is None:
63 pytest.skip(
"Shells API is not available in this client")
65 shells = client.shells.get_all_asset_administration_shells()
67 raise RuntimeError(
"No shells found on server. Please check the server configuration.")
71@pytest.fixture(scope="module")
74 return model_builder.create_base_submodel_element_property(
"sme_property_string", model.datatypes.String,
"Sample String Value", description=
"This is a sample string property for unit testing.", display_name=
"Sample String Property")
76@pytest.fixture(scope="module")
79 return model_builder.create_base_submodel_element_property(
"sme_property_bool", model.datatypes.Boolean,
True, description=
"This is a sample boolean property for unit testing.", display_name=
"Sample Boolean Property")
81@pytest.fixture(scope="module")
84 return model_builder.create_base_submodel_element_property(
"sme_property_int", model.datatypes.Integer, 262, description=
"This is a sample integer property for unit testing.", display_name=
"Sample Integer Property")
86@pytest.fixture(scope="module")
89 return model_builder.create_base_submodel_element_property(
"sme_property_float", model.datatypes.Float, 262.3, description=
"This is a sample float property for unit testing.", display_name=
"Sample Float Property")
91@pytest.fixture(scope="module")
94 values: list[model.SubmodelElement] = []
95 values.append(model_builder.create_base_submodel_element_property(
"coll_element_1", model.datatypes.Integer, 262, description=
"This is a sample integer property for unit testing.", display_name=
"Sample Integer Property"))
96 values.append(model_builder.create_base_submodel_element_property(
"coll_element_2", model.datatypes.String,
"262", description=
"This is a sample string property for unit testing.", display_name=
"Sample String Property"))
97 values.append(model_builder.create_base_submodel_element_property(
"coll_element_3", model.datatypes.Float, 262.3, description=
"This is a sample float property for unit testing.", display_name=
"Sample Float Property"))
99 return model_builder.create_base_submodel_element_collection(
"sme_property_collection", values, description=
"This is a sample collection property for unit testing.", display_name=
"Sample Collection Property")
101@pytest.fixture(scope="module")
104 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.")
106@pytest.fixture(scope="module")
107def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
109 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.")
112 sdk_tools.add_submodel_to_aas(aas, shared_sm)
117 base_url: str = client.base_url
118 new_client = create_by_url(base_url=base_url)
119 assert new_client
is not None
122 base_url: str = client.base_url
124 config_dict: dict = {
128 new_client = create_by_dict(configuration=config_dict)
129 assert new_client
is not None
132 assert client
is not None
135 if client.shells
is None:
136 pytest.skip(
"Shells API is not available in this client")
138 result = client.shells.get_all_asset_administration_shells()
139 assert result
is not None
140 shells = result.get(
"result", [])
143 shell_id = shell.get(
"id",
"")
145 if client.encoded_ids:
146 shell_id = encoder.encode_base_64(shell_id)
149 delete_result = client.shells.delete_asset_administration_shell_by_id(shell_id)
152 shells_result = client.shells.get_all_asset_administration_shells()
154 if shells_result
is None:
155 raise RuntimeError(
"Failed to retrieve shells after deletion.")
157 shells = shells_result.get(
"result", [])
158 assert len(shells) == 0
161 if client.submodels
is None:
162 pytest.skip(
"Submodels API is not available in this client")
164 result = client.submodels.get_all_submodels()
165 assert result
is not None
166 submodels = result.get(
"result", [])
168 for submodel
in submodels:
169 submodel_id = submodel.get(
"id",
"")
171 if client.encoded_ids:
172 submodel_id = encoder.encode_base_64(submodel_id)
175 delete_result = client.submodels.delete_submodel_by_id(submodel_id)
178 submodels_result = client.submodels.get_all_submodels()
180 if submodels_result
is None:
181 raise RuntimeError(
"Failed to retrieve submodels after deletion.")
183 submodels = submodels_result.get(
"result", [])
184 assert len(submodels) == 0
187 if client.shells
is None:
188 pytest.skip(
"Shells API is not available in this client")
190 result = client.shells.get_all_asset_administration_shells()
191 assert result
is not None
192 shells = result.get(
"result", [])
193 assert len(shells) == 0
196 if client.shells
is None:
197 pytest.skip(
"Shells API is not available in this client")
199 aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
200 aas_data = json.loads(aas_data_string)
201 result = client.shells.post_asset_administration_shell(aas_data)
203 assert result
is not None
204 assert result.get(
"idShort",
"") == shared_aas.id_short
205 assert result.get(
"id",
"") == SHELL_ID
207 get_result = client.shells.get_all_asset_administration_shells()
208 assert get_result
is not None
209 shells = get_result.get(
"result", [])
210 assert len(shells) == 1
211 assert shells[0].get(
"idShort",
"") == shared_aas.id_short
212 assert shells[0].get(
"id",
"") == SHELL_ID
213 submodels = shells[0].get(
"submodels", [])
214 assert len(submodels) == 1
215 submodel: dict = submodels[0]
216 assert len(submodel.get(
"keys", [])) == 1
217 assert submodel.get(
"keys", [])[0].get(
"value",
"") == SM_ID
220 if client.shells
is None:
221 pytest.skip(
"Shells API is not available in this client")
225 if client.encoded_ids:
226 shell_id = encoder.encode_base_64(SHELL_ID)
228 result = client.shells.get_asset_administration_shell_by_id(shell_id)
230 assert result
is not None
231 assert result.get(
"idShort",
"") == shared_aas.id_short
232 assert result.get(
"id",
"") == SHELL_ID
235 if client.shells
is None:
236 pytest.skip(
"Shells API is not available in this client")
238 result = client.shells.get_asset_administration_shell_by_id(
"non_existent_id")
240 assert result
is None
243 if client.shells
is None:
244 pytest.skip(
"Shells API is not available in this client")
246 assert shared_aas.asset_information
is not None
247 assert shared_aas.asset_information.global_asset_id
is not None
249 aas = model.AssetAdministrationShell(id_=shared_aas.asset_information.global_asset_id, asset_information=shared_aas.asset_information)
250 aas.id_short = shared_aas.id_short
252 description_text =
"Put description for unit tests"
253 aas.description = model.MultiLanguageTextType({
"en": description_text})
254 aas.submodel = shared_aas.submodel
256 aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
257 aas_data = json.loads(aas_data_string)
261 if client.encoded_ids:
262 shell_id = encoder.encode_base_64(SHELL_ID)
264 result = client.shells.put_asset_administration_shell_by_id(shell_id, aas_data)
267 get_result = client.shells.get_asset_administration_shell_by_id(shell_id)
269 assert get_result.get(
"idShort",
"") == shared_aas.id_short
270 assert get_result.get(
"id",
"") == SHELL_ID
272 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
273 assert shared_aas.description
is not None
274 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_aas.description.get(
"en",
"")
276 assert len(get_result.get(
"submodels", [])) == len(shared_aas.submodel)
283 sm_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
284 sm_data = json.loads(sm_data_string)
285 client.shells.put_asset_administration_shell_by_id(shell_id, sm_data)
288 if client.shells
is None:
289 pytest.skip(
"Shells API is not available in this client")
292 id_short =
"put_short_id"
293 identifier = f
"fluid40/{id_short}"
294 asset_info = model_builder.create_base_asset_information(identifier)
295 assert asset_info.global_asset_id == identifier
297 aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
298 aas.id_short = id_short
300 description_text = {
"en":
"Updated description for unit tests"}
301 aas.description = model.MultiLanguageTextType(description_text)
303 aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
304 aas_data = json.loads(aas_data_string)
308 if client.encoded_ids:
309 shell_id = encoder.encode_base_64(SHELL_ID)
311 parsed = urlparse(client.base_url)
312 if parsed.port
in PYTHON_SERVER_PORTS:
316 result = client.shells.put_asset_administration_shell_by_id(shell_id, aas_data)
320 get_result = client.shells.get_asset_administration_shell_by_id(shell_id)
321 assert get_result
is not None
322 assert get_result.get(
"description", {})[0].get(
"text",
"") != description_text
323 assert shared_aas.description
is not None
324 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_aas.description.get(
"en",
"")
327 if client.shells
is None:
328 pytest.skip(
"Shells API is not available in this client")
332 if client.encoded_ids:
333 shell_id = encoder.encode_base_64(SHELL_ID)
335 result = client.shells.get_asset_administration_shell_by_id_reference_aas_repository(shell_id)
337 parsed = urlparse(client.base_url)
338 if parsed.port
in JAVA_SERVER_PORTS:
340 assert result
is None
342 assert result
is not None
343 keys = result.get(
"keys", [])
344 assert len(keys) == 1
345 assert keys[0].get(
"value",
"") == SHELL_ID
348 if client.shells
is None:
349 pytest.skip(
"Shells API is not available in this client")
354 if client.encoded_ids:
355 shell_id = encoder.encode_base_64(SHELL_ID)
356 sm_id = encoder.encode_base_64(SM_ID)
358 result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
360 assert result
is None
363 if client.submodels
is None:
364 pytest.skip(
"Submodel API is not available in this client")
366 result = client.submodels.get_all_submodels()
367 assert result
is not None
368 submodels = result.get(
"result", [])
369 assert len(submodels) == 0
372 if client.submodels
is None:
373 pytest.skip(
"Submodel API is not available in this client")
375 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
376 sm_data = json.loads(sm_data_string)
378 result = client.submodels.post_submodel(sm_data)
380 assert result
is not None
381 result_id_short = result.get(
"idShort",
"")
382 assert result_id_short == shared_sm.id_short
384 get_result = client.submodels.get_all_submodels()
385 assert get_result
is not None
386 submodels = get_result.get(
"result", [])
387 assert len(submodels) == 1
388 assert submodels[0].get(
"idShort",
"") == shared_sm.id_short
391 if client.submodels
is None:
392 pytest.skip(
"Submodel API is not available in this client")
394 sm_template_file = Path(f
"./tests/test_data/aimc.json").resolve()
396 with Path.open(sm_template_file,
"r", encoding=
"utf-8")
as f:
397 sm_data = json.load(f)
399 result = client.submodels.post_submodel(sm_data)
401 assert result
is not None
402 result_id = result.get(
"id",
"")
403 assert result_id == AIMC_SM_ID
405 get_result = client.submodels.get_all_submodels()
406 assert get_result
is not None
407 submodels = get_result.get(
"result", [])
408 assert len(submodels) == 2
411 if client.shells
is None:
412 pytest.skip(
"Shells API is not available in this client")
417 if client.encoded_ids:
418 shell_id = encoder.encode_base_64(SHELL_ID)
419 sm_id = encoder.encode_base_64(SM_ID)
421 result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
423 parsed = urlparse(client.base_url)
424 if parsed.port
in JAVA_SERVER_PORTS:
426 assert result
is None
428 assert result
is not None
429 result_id_short = result.get(
"idShort",
"")
430 assert result_id_short == shared_sm.id_short
433 if client.submodels
is None:
434 pytest.skip(
"Submodel API is not available in this client")
438 if client.encoded_ids:
439 sm_id = encoder.encode_base_64(SM_ID)
441 result = client.submodels.get_submodel_by_id(sm_id)
443 assert result
is not None
444 result_id_short = result.get(
"idShort",
"")
445 assert result_id_short == shared_sm.id_short
448 if client.submodels
is None:
449 pytest.skip(
"Submodel API is not available in this client")
451 result = client.submodels.get_submodel_by_id(
"non_existent_id")
453 assert result
is None
456 if client.submodels
is None:
457 pytest.skip(
"Submodel API is not available in this client")
461 if client.encoded_ids:
462 sm_id = encoder.encode_base_64(AIMC_SM_ID)
464 result = client.submodels.get_submodel_by_id(sm_id)
466 assert result
is not None
467 result_id = result.get(
"id",
"")
468 assert result_id == AIMC_SM_ID
471 if client.submodels
is None:
472 pytest.skip(
"Submodel API is not available in this client")
476 if client.encoded_ids:
477 sm_id = encoder.encode_base_64(AIMC_SM_ID)
479 result = client.submodels.get_submodel_by_id(sm_id, level=
"core")
481 assert result
is not None
482 result_id = result.get(
"id",
"")
483 assert result_id == AIMC_SM_ID
487 if client.submodels
is None:
488 pytest.skip(
"Submodel API is not available in this client")
490 sm = model.Submodel(shared_sm.id)
491 sm.id_short = shared_sm.id_short
493 description_text =
"Patched description for unit tests"
494 sm.description = model.MultiLanguageTextType({
"en": description_text})
496 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
497 sm_data = json.loads(sm_data_string)
501 if client.encoded_ids:
502 sm_id = encoder.encode_base_64(SM_ID)
504 result = client.submodels.patch_submodel_by_id(sm_id, sm_data)
506 parsed = urlparse(client.base_url)
507 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
511 assert result
is True
513 get_result = client.submodels.get_submodel_by_id(sm_id)
514 assert get_result
is not None
515 assert get_result.get(
"idShort",
"") == shared_sm.id_short
516 assert get_result.get(
"id",
"") == SM_ID
518 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
519 assert shared_sm.description
is not None
520 assert shared_sm.display_name
is not None
521 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
523 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sm.display_name.get(
"en",
"")
526 if client.shells
is None:
527 pytest.skip(
"Shells API is not available in this client")
529 sm = model.Submodel(SM_ID)
530 sm.id_short = shared_sm.id_short
532 description_text =
"Put via shell description for unit tests"
533 sm.description = model.MultiLanguageTextType({
"en": description_text})
535 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
536 sm_data = json.loads(sm_data_string)
541 if client.encoded_ids:
542 shell_id = encoder.encode_base_64(SHELL_ID)
543 sm_id = encoder.encode_base_64(SM_ID)
545 result = client.shells.put_submodel_by_id_aas_repository(shell_id, sm_id, sm_data)
547 parsed = urlparse(client.base_url)
548 if parsed.port
in JAVA_SERVER_PORTS:
554 get_result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
555 assert get_result
is not None
556 assert get_result.get(
"idShort",
"") == shared_sm.id_short
557 assert get_result.get(
"id",
"") == SM_ID
559 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
560 assert shared_sm.description
is not None
561 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
562 assert len(get_result.get(
"displayName", {})) == 0
565 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
566 sm_data = json.loads(sm_data_string)
567 client.shells.put_submodel_by_id_aas_repository(shell_id, sm_id, sm_data)
570 if client.submodels
is None:
571 pytest.skip(
"Submodels API is not available in this client")
573 sm = model.Submodel(SM_ID)
574 sm.id_short = shared_sm.id_short
576 description_text =
"Put description for unit tests"
577 sm.description = model.MultiLanguageTextType({
"en": description_text})
579 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
580 sm_data = json.loads(sm_data_string)
584 if client.encoded_ids:
585 sm_id = encoder.encode_base_64(SM_ID)
587 result = client.submodels.put_submodels_by_id(sm_id, sm_data)
589 assert result
is True
591 get_result = client.submodels.get_submodel_by_id(sm_id)
592 assert get_result
is not None
593 assert get_result.get(
"idShort",
"") == shared_sm.id_short
594 assert get_result.get(
"id",
"") == SM_ID
596 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
597 assert shared_sm.description
is not None
598 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
599 assert len(get_result.get(
"displayName", {})) == 0
602 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
603 sm_data = json.loads(sm_data_string)
604 client.submodels.put_submodels_by_id(SM_ID, sm_data)
607 if client.submodels
is None:
608 pytest.skip(
"Submodels API is not available in this client")
612 if client.encoded_ids:
613 sm_id = encoder.encode_base_64(SM_ID)
615 submodel_elements = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
617 assert submodel_elements
is not None
618 assert len(submodel_elements.get(
"result", [])) == 0
621 if client.submodels
is None:
622 pytest.skip(
"Submodels API is not available in this client")
624 sme_data_string = json.dumps(shared_sme_string, cls=basyx.aas.adapter.json.AASToJsonEncoder)
625 sme_data = json.loads(sme_data_string)
629 if client.encoded_ids:
630 sm_id = encoder.encode_base_64(SM_ID)
632 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
634 assert result
is not None
635 assert result.get(
"idShort",
"") == shared_sme_string.id_short
636 assert shared_sme_string.description
is not None
637 assert shared_sme_string.display_name
is not None
638 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
639 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
640 assert result.get(
"value",
"") == shared_sme_string.value
642 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
643 assert get_result
is not None
645 assert len(get_result.get(
"result", [])) == 1
648 if client.submodels
is None:
649 pytest.skip(
"Submodels API is not available in this client")
651 sme_data_string = json.dumps(shared_sme_bool, cls=basyx.aas.adapter.json.AASToJsonEncoder)
652 sme_data = json.loads(sme_data_string)
656 if client.encoded_ids:
657 sm_id = encoder.encode_base_64(SM_ID)
659 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
661 assert result
is not None
662 assert result.get(
"idShort",
"") == shared_sme_bool.id_short
663 assert shared_sme_bool.description
is not None
664 assert shared_sme_bool.display_name
is not None
665 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
666 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
667 assert json.loads(result.get(
"value",
"").lower()) == shared_sme_bool.value
669 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
670 assert get_result
is not None
672 assert len(get_result.get(
"result", [])) == 2
675 if client.submodels
is None:
676 pytest.skip(
"Submodels API is not available in this client")
678 sme_data_string = json.dumps(shared_sme_int, cls=basyx.aas.adapter.json.AASToJsonEncoder)
679 sme_data = json.loads(sme_data_string)
683 if client.encoded_ids:
684 sm_id = encoder.encode_base_64(SM_ID)
686 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
688 assert result
is not None
689 assert result.get(
"idShort",
"") == shared_sme_int.id_short
690 assert shared_sme_int.description
is not None
691 assert shared_sme_int.display_name
is not None
692 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
693 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
694 assert int(result.get(
"value",
"")) == shared_sme_int.value
696 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
697 assert get_result
is not None
699 assert len(get_result.get(
"result", [])) == 3
702 if client.submodels
is None:
703 pytest.skip(
"Submodels API is not available in this client")
705 sme_data_string = json.dumps(shared_sme_float, cls=basyx.aas.adapter.json.AASToJsonEncoder)
706 sme_data = json.loads(sme_data_string)
710 if client.encoded_ids:
711 sm_id = encoder.encode_base_64(SM_ID)
713 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
715 assert result
is not None
716 assert result.get(
"idShort",
"") == shared_sme_float.id_short
717 assert shared_sme_float.description
is not None
718 assert shared_sme_float.display_name
is not None
719 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
720 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
721 assert float(result.get(
"value",
"")) == shared_sme_float.value
723 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
724 assert get_result
is not None
726 assert len(get_result.get(
"result", [])) == 4
729 if client.submodels
is None:
730 pytest.skip(
"Submodels API is not available in this client")
734 if client.encoded_ids:
735 sm_id = encoder.encode_base_64(SM_ID)
737 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
739 assert result
is not None
740 assert result.get(
"idShort",
"") == shared_sme_string.id_short
741 assert shared_sme_string.description
is not None
742 assert shared_sme_string.display_name
is not None
743 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
744 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
745 assert result.get(
"value",
"") == shared_sme_string.value
748 if client.submodels
is None:
749 pytest.skip(
"Submodels API is not available in this client")
753 if client.encoded_ids:
754 sm_id = encoder.encode_base_64(SM_ID)
756 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
758 assert result
is not None
759 assert result.get(
"idShort",
"") == shared_sme_bool.id_short
760 assert shared_sme_bool.description
is not None
761 assert shared_sme_bool.display_name
is not None
762 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
763 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
764 assert json.loads(result.get(
"value",
"").lower()) == shared_sme_bool.value
767 if client.submodels
is None:
768 pytest.skip(
"Submodels API is not available in this client")
772 if client.encoded_ids:
773 sm_id = encoder.encode_base_64(SM_ID)
775 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
777 assert result
is not None
778 assert result.get(
"idShort",
"") == shared_sme_int.id_short
779 assert shared_sme_int.description
is not None
780 assert shared_sme_int.display_name
is not None
781 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
782 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
783 assert int(result.get(
"value",
"")) == shared_sme_int.value
786 if client.submodels
is None:
787 pytest.skip(
"Submodels API is not available in this client")
791 if client.encoded_ids:
792 sm_id = encoder.encode_base_64(SM_ID)
794 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
796 assert result
is not None
797 assert result.get(
"idShort",
"") == shared_sme_float.id_short
798 assert shared_sme_float.description
is not None
799 assert shared_sme_float.display_name
is not None
800 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
801 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
802 assert float(result.get(
"value",
"")) == shared_sme_float.value
805 if client.submodels
is None:
806 pytest.skip(
"Submodels API is not available in this client")
808 new_value =
"Patched String Value"
812 if client.encoded_ids:
813 sm_id = encoder.encode_base_64(SM_ID)
815 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
816 assert submodel_element
is not None
818 old_value = submodel_element.get(
"value",
"")
820 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_string.id_short, new_value)
822 parsed = urlparse(client.base_url)
823 if parsed.port
in PYTHON_SERVER_PORTS:
825 assert result
is False
827 assert result
is True
829 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
831 assert get_result
is not None
832 assert get_result.get(
"idShort",
"") == shared_sme_string.id_short
833 assert get_result.get(
"value",
"") == new_value
834 assert shared_sme_string.description
is not None
835 assert shared_sme_string.display_name
is not None
836 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
837 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
838 assert get_result.get(
"value",
"") != old_value
841 if client.submodels
is None:
842 pytest.skip(
"Submodels API is not available in this client")
848 if client.encoded_ids:
849 sm_id = encoder.encode_base_64(SM_ID)
851 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
852 assert submodel_element
is not None
854 old_value = submodel_element.get(
"value",
"")
856 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_bool.id_short, new_value)
858 parsed = urlparse(client.base_url)
859 if parsed.port
in PYTHON_SERVER_PORTS:
861 assert result
is False
863 assert result
is True
865 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
867 assert get_result
is not None
868 assert get_result.get(
"idShort",
"") == shared_sme_bool.id_short
869 assert json.loads(get_result.get(
"value",
"").lower()) == json.loads(new_value)
870 assert shared_sme_bool.description
is not None
871 assert shared_sme_bool.display_name
is not None
872 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
873 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
874 assert get_result.get(
"value",
"").lower() != old_value.lower()
877 if client.submodels
is None:
878 pytest.skip(
"Submodels API is not available in this client")
884 if client.encoded_ids:
885 sm_id = encoder.encode_base_64(SM_ID)
887 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
888 assert submodel_element
is not None
890 old_value = submodel_element.get(
"value",
"")
892 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_int.id_short, new_value)
894 parsed = urlparse(client.base_url)
895 if parsed.port
in PYTHON_SERVER_PORTS:
897 assert result
is False
899 assert result
is True
901 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
903 assert get_result
is not None
904 assert get_result.get(
"idShort",
"") == shared_sme_int.id_short
905 assert int(get_result.get(
"value",
"")) == int(new_value)
906 assert shared_sme_int.description
is not None
907 assert shared_sme_int.display_name
is not None
908 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
909 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
910 assert int(get_result.get(
"value",
"")) != int(old_value)
913 if client.submodels
is None:
914 pytest.skip(
"Submodels API is not available in this client")
920 if client.encoded_ids:
921 sm_id = encoder.encode_base_64(SM_ID)
923 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
924 assert submodel_element
is not None
926 old_value = submodel_element.get(
"value",
"")
928 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_float.id_short, new_value)
930 parsed = urlparse(client.base_url)
931 if parsed.port
in PYTHON_SERVER_PORTS:
933 assert result
is False
935 assert result
is True
937 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
939 assert get_result
is not None
940 assert get_result.get(
"idShort",
"") == shared_sme_float.id_short
941 assert float(get_result.get(
"value",
"")) == float(new_value)
942 assert shared_sme_float.description
is not None
943 assert shared_sme_float.display_name
is not None
944 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
945 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
946 assert float(get_result.get(
"value",
"")) != float(old_value)
949 if client.submodels
is None:
950 pytest.skip(
"Submodels API is not available in this client")
952 submodel_element_list = model.SubmodelElementList(id_short=
"sme_list_1", type_value_list_element=model.Property, value_type_list_element=model.datatypes.String)
953 submodel_element_list_dict = sdk_tools.convert_to_dict(submodel_element_list)
954 assert submodel_element_list_dict
is not None
958 if client.encoded_ids:
959 sm_id = encoder.encode_base_64(SM_ID)
961 post_list_element_result = client.submodels.post_submodel_element_submodel_repo(sm_id, submodel_element_list_dict)
963 assert post_list_element_result
is not None
965 property = model_builder.create_base_submodel_element_property(
None, model.datatypes.String,
"Value in List")
966 property_dict = sdk_tools.convert_to_dict(property)
967 assert property_dict
is not None
968 assert "idShort" not in property_dict
970 result = client.submodels.post_submodel_element_by_path_submodel_repo(sm_id, submodel_element_list.id_short, property_dict)
972 assert result
is not None
973 assert "idShort" not in result
975 submodel = client.submodels.get_submodel_by_id(sm_id)
977 assert submodel
is not None
978 elements = submodel.get(
"submodelElements", [])
979 assert len(elements) == 5
980 assert elements[4].get(
"idShort",
"") == submodel_element_list.id_short
981 list_elements = elements[4].get(
"value", [])
982 assert len(list_elements) == 1
983 assert list_elements[0].get(
"idShort",
"") ==
""
984 assert list_elements[0].get(
"value",
"") == property.value
988 if client.submodels
is None:
989 pytest.skip(
"Submodels API is not available in this client")
991 submodel_element_collection = model.SubmodelElementCollection(id_short=
"sme_collection_1")
992 submodel_element_collection_dict = sdk_tools.convert_to_dict(submodel_element_collection)
993 assert submodel_element_collection_dict
is not None
997 if client.encoded_ids:
998 sm_id = encoder.encode_base_64(SM_ID)
1000 first_result = client.submodels.post_submodel_element_submodel_repo(sm_id, submodel_element_collection_dict)
1002 assert first_result
is not None
1004 property = model_builder.create_base_submodel_element_property(
"sme_property_in_collection", model.datatypes.String,
"Value in List")
1005 property_dict = sdk_tools.convert_to_dict(property)
1006 assert property_dict
is not None
1008 result = client.submodels.post_submodel_element_by_path_submodel_repo(sm_id, submodel_element_collection.id_short, property_dict)
1010 assert result
is not None
1011 assert result[
"idShort"] == property.id_short
1013 submodel = client.submodels.get_submodel_by_id(sm_id)
1015 assert submodel
is not None
1016 elements = submodel.get(
"submodelElements", [])
1017 assert len(elements) == 6
1018 assert elements[5].get(
"idShort",
"") == submodel_element_collection.id_short
1019 list_elements = elements[5].get(
"value", [])
1020 assert len(list_elements) == 1
1021 assert list_elements[0].get(
"idShort",
"") == property.id_short
1022 assert list_elements[0].get(
"value",
"") == property.value
1024 base_url: str = client.base_url
1025 new_client = create_by_url(base_url=base_url)
1026 assert new_client
is not None
1027 assert new_client.submodels
is not None
1029 sm = new_client.submodels.get_submodel_by_id(AIMC_SM_ID)
1032 decoded_id = encoder.encode_base_64(AIMC_SM_ID)
1033 decoded_sm = new_client.submodels.get_submodel_by_id(decoded_id)
1034 assert decoded_sm
is not None
1035 assert decoded_sm.get(
"id",
"") == AIMC_SM_ID
1038 base_url: str = client.base_url
1039 new_client = create_by_url(base_url=base_url)
1040 assert new_client
is not None
1041 assert new_client.shells
is not None
1043 sm = new_client.shells.get_asset_administration_shell_by_id(SHELL_ID)
1046 decoded_id = encoder.encode_base_64(SHELL_ID)
1047 decoded_sm = new_client.shells.get_asset_administration_shell_by_id(decoded_id)
1048 assert decoded_sm
is not None
1049 assert decoded_sm.get(
"id",
"") == SHELL_ID
1052 if client.experimental
is None:
1053 pytest.skip(
"Experimental API is not available in this client")
1055 if client.submodels
is None:
1056 pytest.skip(
"Submodels API is not available in this client")
1058 parsed = urlparse(client.base_url)
1059 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1066 if client.encoded_ids:
1067 sm_id = encoder.encode_base_64(SM_ID)
1069 file_sme = model.File(
"file_sme", content_type=
"application/pdf")
1070 file_post_result = client.submodels.post_submodel_element_submodel_repo(sm_id, sdk_tools.convert_to_dict(file_sme))
1071 assert file_post_result
is not None
1073 filename =
"https.pdf"
1074 file = Path(f
"./tests/test_data/{filename}").resolve()
1075 result = client.experimental.post_file_by_path_submodel_repo(sm_id, file_sme.id_short, file)
1076 assert result
is True
1078 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, file_sme.id_short)
1080 assert result_sme
is not None
1081 assert result_sme.get(
"idShort",
"") == file_sme.id_short
1082 assert result_sme.get(
"contentType",
"") == file_sme.content_type
1083 assert "value" in result_sme
1084 assert result_sme.get(
"value",
"") == f
"/{filename}"
1087 if client.experimental
is None:
1088 pytest.skip(
"Experimental API is not available in this client")
1090 parsed = urlparse(client.base_url)
1091 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1098 if client.encoded_ids:
1099 sm_id = encoder.encode_base_64(SM_ID)
1101 result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1102 assert result
is not None
1103 assert len(result) > 0
1104 assert result.startswith(b
"%PDF-1.7")
1107 if client.experimental
is None:
1108 pytest.skip(
"Experimental API is not available in this client")
1110 if client.submodels
is None:
1111 pytest.skip(
"Submodels API is not available in this client")
1113 parsed = urlparse(client.base_url)
1114 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1121 if client.encoded_ids:
1122 sm_id = encoder.encode_base_64(SM_ID)
1124 filename =
"aimc.json"
1125 file = Path(f
"./tests/test_data/{filename}").resolve()
1126 result = client.experimental.put_file_by_path_submodel_repo(sm_id,
"file_sme", file)
1127 assert result
is True
1129 get_result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1130 assert get_result
is not None
1131 assert len(get_result) > 0
1132 assert get_result.startswith(b
"{\n")
1134 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id,
"file_sme")
1135 assert result_sme
is not None
1136 assert "value" in result_sme
1137 assert result_sme.get(
"value",
"") == f
"/{filename}"
1140 if client.experimental
is None:
1141 pytest.skip(
"Experimental API is not available in this client")
1143 if client.submodels
is None:
1144 pytest.skip(
"Submodels API is not available in this client")
1146 parsed = urlparse(client.base_url)
1147 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1153 if client.encoded_ids:
1154 sm_id = encoder.encode_base_64(SM_ID)
1156 result = client.experimental.delete_file_by_path_submodel_repo(sm_id,
"file_sme")
1157 assert result
is True
1159 get_result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1160 assert get_result
is None
1162 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id,
"file_sme")
1163 assert result_sme
is not None
1164 assert "value" in result_sme
1165 assert result_sme.get(
"value",
"") ==
None
1168 if client.shells
is None:
1169 pytest.skip(
"Shells API is not available in this client")
1171 parsed = urlparse(client.base_url)
1172 if parsed.port
in PYTHON_SERVER_PORTS:
1178 if client.encoded_ids:
1179 shell_id = encoder.encode_base_64(SHELL_ID)
1181 result = client.shells.get_thumbnail_aas_repository(shell_id)
1182 assert result
is None
1187 if client.shells
is None:
1188 pytest.skip(
"Shells API is not available in this client")
1190 parsed = urlparse(client.base_url)
1191 if parsed.port
in PYTHON_SERVER_PORTS:
1197 if client.encoded_ids:
1198 shell_id = encoder.encode_base_64(SHELL_ID)
1200 filename =
"Pen_Machine.png"
1201 file = Path(f
"./tests/test_data/{filename}").resolve()
1203 result = client.shells.put_thumbnail_aas_repository(shell_id, file.name, file)
1204 assert result
is True
1207 if client.shells
is None:
1208 pytest.skip(
"Shells API is not available in this client")
1210 parsed = urlparse(client.base_url)
1211 if parsed.port
in PYTHON_SERVER_PORTS:
1217 if client.encoded_ids:
1218 shell_id = encoder.encode_base_64(SHELL_ID)
1220 result = client.shells.get_thumbnail_aas_repository(shell_id)
1221 assert result
is not None
1222 assert len(result) > 0
1223 assert result.startswith(b
"\x89PNG\r\n\x1a\n")
1226 if client.shells
is None:
1227 pytest.skip(
"Shells API is not available in this client")
1229 parsed = urlparse(client.base_url)
1230 if parsed.port
in PYTHON_SERVER_PORTS:
1236 if client.encoded_ids:
1237 shell_id = encoder.encode_base_64(SHELL_ID)
1239 result = client.shells.delete_thumbnail_aas_repository(shell_id)
1240 assert result
is True
1242 get_result = client.shells.get_thumbnail_aas_repository(shell_id)
1243 assert get_result
is None
1246 if client.shells
is None:
1247 pytest.skip(
"Shells API is not available in this client")
1249 parsed = urlparse(client.base_url)
1250 if parsed.port
in PYTHON_SERVER_PORTS:
1256 if client.encoded_ids:
1257 shell_id = encoder.encode_base_64(SHELL_ID)
1259 filename =
"Pen_Machine.png"
1260 file = Path(f
"./tests/test_data/{filename}").resolve()
1262 with file.open(
"rb")
as f:
1263 file_octet_stream = f.read()
1265 result = client.shells.put_thumbnail_aas_repository_stream(shell_id, file.name, file_octet_stream,
"image/png")
1266 assert result
is True
1268 get_result = client.shells.get_thumbnail_aas_repository(shell_id)
1269 assert get_result
is not None
1270 assert len(get_result) > 0
1271 assert get_result.startswith(b
"\x89PNG\r\n\x1a\n")
1273 delete_result = client.shells.delete_thumbnail_aas_repository(shell_id)
1274 assert delete_result
is True
1276 get_result = client.shells.get_thumbnail_aas_repository(shell_id)
1277 assert get_result
is None
1280 if client.shells
is None:
1281 pytest.skip(
"Shells API is not available in this client")
1285 if client.encoded_ids:
1286 shell_id = encoder.encode_base_64(SHELL_ID)
1288 result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1289 assert result
is not None
1290 references = result.get(
"result", [])
1291 assert len(references) == 1
1294 if client.shells
is None:
1295 pytest.skip(
"Shells API is not available in this client")
1299 if client.encoded_ids:
1300 shell_id = encoder.encode_base_64(SHELL_ID)
1304 temp_sml_ref = model.ModelReference.from_referable(model_builder.create_base_submodel(identifier=id, id_short=id_short))
1306 result = client.shells.post_submodel_reference_aas_repository(shell_id, sdk_tools.convert_to_dict(temp_sml_ref))
1308 assert result
is not None
1309 assert len(result.get(
"keys", [])) > 0
1310 key: dict = result.get(
"keys", [])[0]
1311 assert key.get(
"value",
"") == id
1312 assert key.get(
"type",
"") ==
"Submodel"
1314 check_result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1315 assert check_result
is not None
1316 check_references = check_result.get(
"result", [])
1317 assert len(check_references) == 2
1320 if client.shells
is None:
1321 pytest.skip(
"Submodels API is not available in this client")
1324 sm_id =
"temp_sm_id"
1326 if client.encoded_ids:
1327 shell_id = encoder.encode_base_64(SHELL_ID)
1328 sm_id = encoder.encode_base_64(sm_id)
1330 result = client.shells.delete_submodel_reference_by_id_aas_repository(shell_id, sm_id)
1332 assert result
is True
1334 get_result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1335 assert get_result
is not None
1336 references = get_result.get(
"result", [])
1337 assert len(references) == 1
1340 if client.submodels
is None:
1341 pytest.skip(
"Submodels API is not available in this client")
1345 if client.encoded_ids:
1346 sm_id = encoder.encode_base_64(SM_ID)
1348 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1349 assert get_result
is not None
1350 old_value = get_result.get(
"value",
"")
1352 new_value =
"New Value via PUT"
1354 sme_data_string = json.dumps(shared_sme_string, cls=basyx.aas.adapter.json.AASToJsonEncoder)
1355 sme_data = json.loads(sme_data_string)
1356 sme_data[
"value"] = new_value
1358 result = client.submodels.put_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short, sme_data)
1360 assert result
is True
1362 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1364 assert get_result
is not None
1365 assert get_result.get(
"idShort",
"") == shared_sme_string.id_short
1366 assert get_result.get(
"value",
"") == new_value
1367 assert get_result.get(
"value",
"") != old_value
1368 assert shared_sme_string.description
is not None
1369 assert shared_sme_string.display_name
is not None
1370 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
1371 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
1374 sme_data[
"value"] =
"Sample String Value"
1375 result = client.submodels.put_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short, sme_data)
1378 if client.submodels
is None:
1379 pytest.skip(
"Submodels API is not available in this client")
1383 if client.encoded_ids:
1384 sm_id = encoder.encode_base_64(SM_ID)
1386 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_string.id_short)
1388 parsed = urlparse(client.base_url)
1389 if parsed.port
in PYTHON_SERVER_PORTS:
1391 assert value
is None
1394 assert value
is not None
1396 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1397 assert sm_data
is not None
1398 assert value == sm_data.get(
"value",
"")
1401 if client.submodels
is None:
1402 pytest.skip(
"Submodels API is not available in this client")
1406 if client.encoded_ids:
1407 sm_id = encoder.encode_base_64(SM_ID)
1409 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_int.id_short)
1411 parsed = urlparse(client.base_url)
1412 if parsed.port
in PYTHON_SERVER_PORTS:
1414 assert value
is None
1417 assert value
is not None
1419 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
1420 assert sm_data
is not None
1421 assert int(value) == int(sm_data.get(
"value",
""))
1424 if client.submodels
is None:
1425 pytest.skip(
"Submodels API is not available in this client")
1429 if client.encoded_ids:
1430 sm_id = encoder.encode_base_64(SM_ID)
1432 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_float.id_short)
1434 parsed = urlparse(client.base_url)
1435 if parsed.port
in PYTHON_SERVER_PORTS:
1437 assert value
is None
1440 assert value
is not None
1442 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
1443 assert sm_data
is not None
1444 assert float(value) == float(sm_data.get(
"value",
""))
1447 if client.submodels
is None:
1448 pytest.skip(
"Submodels API is not available in this client")
1452 if client.encoded_ids:
1453 sm_id = encoder.encode_base_64(SM_ID)
1455 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_bool.id_short)
1457 parsed = urlparse(client.base_url)
1458 if parsed.port
in PYTHON_SERVER_PORTS:
1460 assert value
is None
1463 assert value
is not None
1465 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
1466 assert sm_data
is not None
1497 if client.submodels
is None:
1498 pytest.skip(
"Submodels API is not available in this client")
1502 if client.encoded_ids:
1503 sm_id = encoder.encode_base_64(SM_ID)
1505 response = client.submodels.get_submodel_by_id_value_only(sm_id)
1507 parsed = urlparse(client.base_url)
1508 if parsed.port
in PYTHON_SERVER_PORTS:
1510 assert response
is None
1512 elif parsed.port
in DOTNET_SERVER_PORTS:
1513 assert response
is not None
1514 value = response[shared_sm.id_short]
1516 assert response
is not None
1519 assert value
is not None
1520 assert len(value) > 5
1521 assert "sme_property_int" in value
1522 assert int(value[
"sme_property_int"]) == 263
1523 assert "sme_property_string" in value
1524 assert value[
"sme_property_string"] ==
"Sample String Value"
1525 assert "sme_property_float" in value
1526 assert float(value[
"sme_property_float"]) == 262.1
1529 if client.submodels
is None:
1530 pytest.skip(
"Submodels API is not available in this client")
1534 if client.encoded_ids:
1535 sm_id = encoder.encode_base_64(SM_ID)
1538 shared_sme_string.id_short: shared_sme_string.value,
1539 shared_sme_int.id_short: str(shared_sme_int.value),
1540 shared_sme_float.id_short: str(shared_sme_float.value)
1545 patch_dict = value_dict
1547 parsed = urlparse(client.base_url)
1548 if parsed.port
in PYTHON_SERVER_PORTS:
1552 if parsed.port
in JAVA_SERVER_PORTS:
1556 elif parsed.port
in DOTNET_SERVER_PORTS:
1557 patch_dict = value_dict
1559 result = client.submodels.patch_submodel_by_id_value_only(sm_id, patch_dict)
1561 assert result
is True
1563 string_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1564 int_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
1565 float_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
1567 assert string_prop_dict
is not None
1568 assert int_prop_dict
is not None
1569 assert float_prop_dict
is not None
1571 assert string_prop_dict.get(
"value",
"") == shared_sme_string.value
1572 assert int(int_prop_dict.get(
"value",
"")) == int(shared_sme_int.value)
1573 assert float(float_prop_dict.get(
"value",
"")) == float(shared_sme_float.value)
1577 if client.submodels
is None:
1578 pytest.skip(
"Submodels API is not available in this client")
1582 if client.encoded_ids:
1583 sm_id = encoder.encode_base_64(SM_ID)
1585 metadata = client.submodels.get_submodel_by_id_metadata(sm_id)
1586 assert metadata
is not None
1588 submodel = client.submodels.get_submodel_by_id(sm_id)
1589 assert submodel
is not None
1591 assert metadata.get(
"id",
"") == submodel.get(
"id",
"")
1592 assert metadata.get(
"idShort",
"") == submodel.get(
"idShort",
"")
1593 assert metadata.get(
"description", {})[0].get(
"text",
"") == submodel.get(
"description", {})[0].get(
"text",
"")
1594 if "displayName" in submodel
and submodel.get(
"displayName", []):
1595 assert metadata.get(
"displayName", {})[0].get(
"text",
"") == submodel.get(
"displayName", {})[0].get(
"text",
"")
1596 assert "submodelElements" not in metadata
1599 if client.shells
is None:
1600 pytest.skip(
"Shells API is not available in this client")
1604 if client.encoded_ids:
1605 shell_id = encoder.encode_base_64(SHELL_ID)
1607 result = client.shells.delete_asset_administration_shell_by_id(shell_id)
1609 assert result
is True
1611 get_result = client.shells.get_all_asset_administration_shells()
1612 assert get_result
is not None
1613 shells = get_result.get(
"result", [])
1614 assert len(shells) == 0
1617 if client.submodels
is None:
1618 pytest.skip(
"Submodels API is not available in this client")
1622 if client.encoded_ids:
1623 sm_id = encoder.encode_base_64(SM_ID)
1625 result = client.submodels.delete_submodel_by_id(sm_id)
1627 assert result
is True
1629 get_result = client.submodels.get_all_submodels()
1630 assert get_result
is not None
1631 submodels = get_result.get(
"result", [])
1632 assert len(submodels) == 1
1635 if client.submodels
is None:
1636 pytest.skip(
"Submodels API is not available in this client")
1640 if client.encoded_ids:
1641 sm_id = encoder.encode_base_64(AIMC_SM_ID)
1643 result = client.submodels.delete_submodel_by_id(sm_id)
1645 assert result
is True
1647 get_result = client.submodels.get_all_submodels()
1648 assert get_result
is not None
1649 submodels = get_result.get(
"result", [])
1650 assert len(submodels) == 0
test_099b_delete_submodel_by_id(AasHttpClient client)
model.SubmodelElementCollection shared_sme_collection()
test_032_put_submodel_element_by_path_submodel_repo(AasHttpClient client, model.Property shared_sme_string)
test_018b_patch_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_bool)
model.Property shared_sme_float()
test_028a_put_thumbnail_aas_repository_stream(AasHttpClient client)
test_013_put_submodel_by_id_aas_repository(AasHttpClient client, model.Submodel shared_sm)
test_033b_get_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_int)
test_018a_patch_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_string)
test_018d_patch_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_float)
test_016b_post_submodel_element_submodel_repo(AasHttpClient client, model.Property shared_sme_bool)
test_005a_put_asset_administration_shell_by_id(AasHttpClient client, model.AssetAdministrationShell shared_aas)
test_033d_get_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_bool)
test_000b_create_client_by_dict(AasHttpClient client)
model.Submodel shared_sm()
test_029_get_all_submodel_references_aas_repository(AasHttpClient client)
test_026_put_thumbnail_aas_repository(AasHttpClient client)
test_014_put_submodels_by_id(AasHttpClient client, model.Submodel shared_sm)
test_036_get_submodel_by_id_metadata(AasHttpClient client, model.Submodel shared_sm)
test_000a_create_client_by_url(AasHttpClient client)
test_011a_get_submodel_by_id(AasHttpClient client, model.Submodel shared_sm)
test_017d_get_submodel_element_by_path_submodel_repo(AasHttpClient client, model.Property shared_sme_float)
test_021_post_file_by_path_submodel_repo(AasHttpClient client)
test_019b_post_submodel_element_by_path_submodel_repo(AasHttpClient client)
test_007_get_submodel_by_id_aas_repository(AasHttpClient client)
test_016c_post_submodel_element_submodel_repo(AasHttpClient client, model.Property shared_sme_int)
model.AssetAdministrationShell shared_aas(model.Submodel shared_sm)
test_009a_post_submodel(AasHttpClient client, model.Submodel shared_sm)
test_033a_get_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_string)
model.Property shared_sme_string()
test_010_get_submodel_by_id_aas_repository(AasHttpClient client, model.Submodel shared_sm)
test_098_delete_asset_administration_shell_by_id(AasHttpClient client)
test_027_get_thumbnail_aas_repository(AasHttpClient client)
test_009b_post_submodel(AasHttpClient client)
test_002_get_all_asset_administration_shells(AasHttpClient client)
test_011d_get_submodel_by_id(AasHttpClient client)
test_024_delete_file_content_by_path_submodel_repo(AasHttpClient client)
test_015_get_all_submodel_elements_submodel_repository(AasHttpClient client, model.Submodel shared_sm)
test_011c_get_submodel_by_id(AasHttpClient client)
test_012_patch_submodel_by_id(AasHttpClient client, model.Submodel shared_sm)
test_001a_connect(AasHttpClient client)
test_017a_get_submodel_element_by_path_submodel_repo(AasHttpClient client, model.Property shared_sme_string)
test_001c_delete_all_submodels(AasHttpClient client)
test_017c_get_submodel_element_by_path_submodel_repo(AasHttpClient client, model.Property shared_sme_int)
model.Property shared_sme_int()
test_016a_post_submodel_element_submodel_repo(AasHttpClient client, model.Property shared_sme_string)
test_099a_delete_submodel_by_id(AasHttpClient client)
test_005b_put_asset_administration_shell_by_id(AasHttpClient client, model.AssetAdministrationShell shared_aas)
model.Property shared_sme_bool()
test_001b_delete_all_asset_administration_shells(AasHttpClient client)
test_006_get_asset_administration_shell_by_id_reference_aas_repository(AasHttpClient client)
test_031_delete_submodel_reference_by_id_aas_repository(AasHttpClient client)
test_030_post_submodel_reference_aas_repository(AasHttpClient client)
test_004b_get_asset_administration_shell_by_id(AasHttpClient client)
test_035_patch_submodel_by_id_value_only(AasHttpClient client, model.Submodel shared_sm, model.Property shared_sme_string, model.Property shared_sme_int, model.Property shared_sme_float)
test_022_get_file_content_by_path_submodel_repo(AasHttpClient client)
test_018c_patch_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_int)
test_025_get_thumbnail_aas_repository(AasHttpClient client)
test_008_get_all_submodels(AasHttpClient client)
test_011b_get_submodel_by_id(AasHttpClient client)
test_017b_get_submodel_element_by_path_submodel_repo(AasHttpClient client, model.Property shared_sme_bool)
test_003_post_asset_administration_shell(AasHttpClient client, model.AssetAdministrationShell shared_aas)
test_019a_post_submodel_element_by_path_submodel_repo(AasHttpClient client)
test_023_put_file_content_by_path_submodel_repo(AasHttpClient client)
test_004a_get_asset_administration_shell_by_id(AasHttpClient client, model.AssetAdministrationShell shared_aas)
test_028_delete_thumbnail_aas_repository(AasHttpClient client)
test_020b_encoded_ids(AasHttpClient client)
test_033c_get_submodel_element_by_path_value_only_submodel_repo(AasHttpClient client, model.Property shared_sme_float)
test_016d_post_submodel_element_submodel_repo(AasHttpClient client, model.Property shared_sme_float)
test_034_get_submodel_by_id_value_only(AasHttpClient client, model.Submodel shared_sm)