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"
28 "./tests/server_configs/test_java_server_config.yml",
29 "./tests/server_configs/test_dotnet_server_config.yml",
30 "./tests/server_configs/test_python_server_config.yml"
37@pytest.fixture(params=CONFIG_FILES, scope="module")
38def client(request) -> AasHttpClient:
41 file = Path(request.param).resolve()
44 raise FileNotFoundError(f
"Configuration file {file} does not exist.")
46 client = create_by_config(file)
49 raise RuntimeError(
"Failed to create client from configuration file.")
52 rand = random.randint(0, 10)
54 client.encoded_ids =
True
56 except Exception
as e:
57 raise RuntimeError(
"Unable to connect to server.")
60 if client.shells
is None:
61 pytest.skip(
"Shells API is not available in this client")
63 shells = client.shells.get_all_asset_administration_shells()
65 raise RuntimeError(
"No shells found on server. Please check the server configuration.")
69@pytest.fixture(scope="module")
72 return model_builder.create_base_submodel_element_property(
"sme_property_string", model.datatypes.String,
"Sample String Value")
74@pytest.fixture(scope="module")
77 return model_builder.create_base_submodel_element_property(
"sme_property_bool", model.datatypes.Boolean,
True)
79@pytest.fixture(scope="module")
82 return model_builder.create_base_submodel_element_property(
"sme_property_int", model.datatypes.Integer, 262)
84@pytest.fixture(scope="module")
87 return model_builder.create_base_submodel_element_property(
"sme_property_float", model.datatypes.Float, 262.3)
89@pytest.fixture(scope="module")
92 values: list[model.SubmodelElement] = []
93 values.append(model_builder.create_base_submodel_element_property(
"coll_element_1", model.datatypes.Integer, 262))
94 values.append(model_builder.create_base_submodel_element_property(
"coll_element_2", model.datatypes.String,
"262"))
95 values.append(model_builder.create_base_submodel_element_property(
"coll_element_3", model.datatypes.Float, 262.3))
97 return model_builder.create_base_submodel_element_collection(
"sme_property_collection", values)
99@pytest.fixture(scope="module")
102 return model_builder.create_base_submodel(identifier=SM_ID, id_short=
"sm_http_client_unit_tests")
104@pytest.fixture(scope="module")
105def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
107 aas = model_builder.create_base_aas(identifier=SHELL_ID, id_short=
"aas_http_client_unit_tests")
110 sdk_tools.add_submodel_to_aas(aas, shared_sm)
115 base_url: str = client.base_url
116 new_client = create_by_url(base_url=base_url)
117 assert new_client
is not None
120 base_url: str = client.base_url
122 config_dict: dict = {
126 new_client = create_by_dict(configuration=config_dict)
127 assert new_client
is not None
130 assert client
is not None
133 if client.shells
is None:
134 pytest.skip(
"Shells API is not available in this client")
136 result = client.shells.get_all_asset_administration_shells()
137 assert result
is not None
138 shells = result.get(
"result", [])
141 shell_id = shell.get(
"id",
"")
143 if client.encoded_ids:
144 shell_id = encoder.encode_base_64(shell_id)
147 delete_result = client.shells.delete_asset_administration_shell_by_id(shell_id)
150 shells_result = client.shells.get_all_asset_administration_shells()
152 if shells_result
is None:
153 raise RuntimeError(
"Failed to retrieve shells after deletion.")
155 shells = shells_result.get(
"result", [])
156 assert len(shells) == 0
159 if client.submodels
is None:
160 pytest.skip(
"Submodels API is not available in this client")
162 result = client.submodels.get_all_submodels()
163 assert result
is not None
164 submodels = result.get(
"result", [])
166 for submodel
in submodels:
167 submodel_id = submodel.get(
"id",
"")
169 if client.encoded_ids:
170 submodel_id = encoder.encode_base_64(submodel_id)
173 delete_result = client.submodels.delete_submodel_by_id(submodel_id)
176 submodels_result = client.submodels.get_all_submodels()
178 if submodels_result
is None:
179 raise RuntimeError(
"Failed to retrieve submodels after deletion.")
181 submodels = submodels_result.get(
"result", [])
182 assert len(submodels) == 0
185 if client.shells
is None:
186 pytest.skip(
"Shells API is not available in this client")
188 result = client.shells.get_all_asset_administration_shells()
189 assert result
is not None
190 shells = result.get(
"result", [])
191 assert len(shells) == 0
194 if client.shells
is None:
195 pytest.skip(
"Shells API is not available in this client")
197 aas_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
198 aas_data = json.loads(aas_data_string)
199 result = client.shells.post_asset_administration_shell(aas_data)
201 assert result
is not None
202 assert result.get(
"idShort",
"") == shared_aas.id_short
203 assert result.get(
"id",
"") == SHELL_ID
205 get_result = client.shells.get_all_asset_administration_shells()
206 assert get_result
is not None
207 shells = get_result.get(
"result", [])
208 assert len(shells) == 1
209 assert shells[0].get(
"idShort",
"") == shared_aas.id_short
210 assert shells[0].get(
"id",
"") == SHELL_ID
211 submodels = shells[0].get(
"submodels", [])
212 assert len(submodels) == 1
213 submodel: dict = submodels[0]
214 assert len(submodel.get(
"keys", [])) == 1
215 assert submodel.get(
"keys", [])[0].get(
"value",
"") == SM_ID
218 if client.shells
is None:
219 pytest.skip(
"Shells API is not available in this client")
223 if client.encoded_ids:
224 shell_id = encoder.encode_base_64(SHELL_ID)
226 result = client.shells.get_asset_administration_shell_by_id(shell_id)
228 assert result
is not None
229 assert result.get(
"idShort",
"") == shared_aas.id_short
230 assert result.get(
"id",
"") == SHELL_ID
233 if client.shells
is None:
234 pytest.skip(
"Shells API is not available in this client")
236 result = client.shells.get_asset_administration_shell_by_id(
"non_existent_id")
238 assert result
is None
241 if client.shells
is None:
242 pytest.skip(
"Shells API is not available in this client")
244 assert shared_aas.asset_information
is not None
245 assert shared_aas.asset_information.global_asset_id
is not None
247 aas = model.AssetAdministrationShell(id_=shared_aas.asset_information.global_asset_id, asset_information=shared_aas.asset_information)
248 aas.id_short = shared_aas.id_short
250 description_text =
"Put description for unit tests"
251 aas.description = model.MultiLanguageTextType({
"en": description_text})
252 aas.submodel = shared_aas.submodel
254 aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
255 aas_data = json.loads(aas_data_string)
259 if client.encoded_ids:
260 shell_id = encoder.encode_base_64(SHELL_ID)
262 result = client.shells.put_asset_administration_shell_by_id(shell_id, aas_data)
265 get_result = client.shells.get_asset_administration_shell_by_id(shell_id)
267 assert get_result.get(
"idShort",
"") == shared_aas.id_short
268 assert get_result.get(
"id",
"") == SHELL_ID
270 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
271 assert shared_aas.description
is not None
272 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_aas.description.get(
"en",
"")
274 assert len(get_result.get(
"submodels", [])) == len(shared_aas.submodel)
281 sm_data_string = json.dumps(shared_aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
282 sm_data = json.loads(sm_data_string)
283 client.shells.put_asset_administration_shell_by_id(shell_id, sm_data)
286 if client.shells
is None:
287 pytest.skip(
"Shells API is not available in this client")
290 id_short =
"put_short_id"
291 identifier = f
"fluid40/{id_short}"
292 asset_info = model_builder.create_base_asset_information(identifier)
293 assert asset_info.global_asset_id == identifier
295 aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
296 aas.id_short = id_short
298 description_text = {
"en":
"Updated description for unit tests"}
299 aas.description = model.MultiLanguageTextType(description_text)
301 aas_data_string = json.dumps(aas, cls=basyx.aas.adapter.json.AASToJsonEncoder)
302 aas_data = json.loads(aas_data_string)
306 if client.encoded_ids:
307 shell_id = encoder.encode_base_64(SHELL_ID)
309 parsed = urlparse(client.base_url)
310 if parsed.port
in PYTHON_SERVER_PORTS:
314 result = client.shells.put_asset_administration_shell_by_id(shell_id, aas_data)
318 get_result = client.shells.get_asset_administration_shell_by_id(shell_id)
319 assert get_result
is not None
320 assert get_result.get(
"description", {})[0].get(
"text",
"") != description_text
321 assert shared_aas.description
is not None
322 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_aas.description.get(
"en",
"")
325 if client.shells
is None:
326 pytest.skip(
"Shells API is not available in this client")
330 if client.encoded_ids:
331 shell_id = encoder.encode_base_64(SHELL_ID)
333 result = client.shells.get_asset_administration_shell_by_id_reference_aas_repository(shell_id)
335 parsed = urlparse(client.base_url)
336 if parsed.port
in JAVA_SERVER_PORTS:
338 assert result
is None
340 assert result
is not None
341 keys = result.get(
"keys", [])
342 assert len(keys) == 1
343 assert keys[0].get(
"value",
"") == SHELL_ID
346 if client.shells
is None:
347 pytest.skip(
"Shells API is not available in this client")
352 if client.encoded_ids:
353 shell_id = encoder.encode_base_64(SHELL_ID)
354 sm_id = encoder.encode_base_64(SM_ID)
356 result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
358 assert result
is None
361 if client.submodels
is None:
362 pytest.skip(
"Submodel API is not available in this client")
364 result = client.submodels.get_all_submodels()
365 assert result
is not None
366 submodels = result.get(
"result", [])
367 assert len(submodels) == 0
370 if client.submodels
is None:
371 pytest.skip(
"Submodel API is not available in this client")
373 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
374 sm_data = json.loads(sm_data_string)
376 result = client.submodels.post_submodel(sm_data)
378 assert result
is not None
379 result_id_short = result.get(
"idShort",
"")
380 assert result_id_short == shared_sm.id_short
382 get_result = client.submodels.get_all_submodels()
383 assert get_result
is not None
384 submodels = get_result.get(
"result", [])
385 assert len(submodels) == 1
386 assert submodels[0].get(
"idShort",
"") == shared_sm.id_short
389 if client.submodels
is None:
390 pytest.skip(
"Submodel API is not available in this client")
392 sm_template_file = Path(f
"./tests/test_data/aimc.json").resolve()
394 with Path.open(sm_template_file,
"r", encoding=
"utf-8")
as f:
395 sm_data = json.load(f)
397 result = client.submodels.post_submodel(sm_data)
399 assert result
is not None
400 result_id = result.get(
"id",
"")
401 assert result_id == AIMC_SM_ID
403 get_result = client.submodels.get_all_submodels()
404 assert get_result
is not None
405 submodels = get_result.get(
"result", [])
406 assert len(submodels) == 2
409 if client.shells
is None:
410 pytest.skip(
"Shells API is not available in this client")
415 if client.encoded_ids:
416 shell_id = encoder.encode_base_64(SHELL_ID)
417 sm_id = encoder.encode_base_64(SM_ID)
419 result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
421 parsed = urlparse(client.base_url)
422 if parsed.port
in JAVA_SERVER_PORTS:
424 assert result
is None
426 assert result
is not None
427 result_id_short = result.get(
"idShort",
"")
428 assert result_id_short == shared_sm.id_short
431 if client.submodels
is None:
432 pytest.skip(
"Submodel API is not available in this client")
436 if client.encoded_ids:
437 sm_id = encoder.encode_base_64(SM_ID)
439 result = client.submodels.get_submodel_by_id(sm_id)
441 assert result
is not None
442 result_id_short = result.get(
"idShort",
"")
443 assert result_id_short == shared_sm.id_short
446 if client.submodels
is None:
447 pytest.skip(
"Submodel API is not available in this client")
449 result = client.submodels.get_submodel_by_id(
"non_existent_id")
451 assert result
is None
454 if client.submodels
is None:
455 pytest.skip(
"Submodel API is not available in this client")
459 if client.encoded_ids:
460 sm_id = encoder.encode_base_64(AIMC_SM_ID)
462 result = client.submodels.get_submodel_by_id(sm_id)
464 assert result
is not None
465 result_id = result.get(
"id",
"")
466 assert result_id == AIMC_SM_ID
469 if client.submodels
is None:
470 pytest.skip(
"Submodel API is not available in this client")
474 if client.encoded_ids:
475 sm_id = encoder.encode_base_64(AIMC_SM_ID)
477 result = client.submodels.get_submodel_by_id(sm_id, level=
"core")
479 assert result
is not None
480 result_id = result.get(
"id",
"")
481 assert result_id == AIMC_SM_ID
485 if client.submodels
is None:
486 pytest.skip(
"Submodel API is not available in this client")
488 sm = model.Submodel(shared_sm.id_short)
489 sm.id_short = shared_sm.id_short
491 description_text =
"Patched description for unit tests"
492 sm.description = model.MultiLanguageTextType({
"en": description_text})
494 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
495 sm_data = json.loads(sm_data_string)
499 if client.encoded_ids:
500 sm_id = encoder.encode_base_64(SM_ID)
502 result = client.submodels.patch_submodel_by_id(sm_id, sm_data)
504 parsed = urlparse(client.base_url)
505 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
509 assert result
is True
511 get_result = client.submodels.get_submodel_by_id(sm_id)
512 assert get_result
is not None
513 assert get_result.get(
"idShort",
"") == shared_sm.id_short
514 assert get_result.get(
"id",
"") == SM_ID
516 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
517 assert shared_sm.description
is not None
518 assert shared_sm.display_name
is not None
519 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
521 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sm.display_name.get(
"en",
"")
524 if client.shells
is None:
525 pytest.skip(
"Shells API is not available in this client")
527 sm = model.Submodel(SM_ID)
528 sm.id_short = shared_sm.id_short
530 description_text =
"Put via shell description for unit tests"
531 sm.description = model.MultiLanguageTextType({
"en": description_text})
533 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
534 sm_data = json.loads(sm_data_string)
539 if client.encoded_ids:
540 shell_id = encoder.encode_base_64(SHELL_ID)
541 sm_id = encoder.encode_base_64(SM_ID)
543 result = client.shells.put_submodel_by_id_aas_repository(shell_id, sm_id, sm_data)
545 parsed = urlparse(client.base_url)
546 if parsed.port
in JAVA_SERVER_PORTS:
552 get_result = client.shells.get_submodel_by_id_aas_repository(shell_id, sm_id)
553 assert get_result
is not None
554 assert get_result.get(
"idShort",
"") == shared_sm.id_short
555 assert get_result.get(
"id",
"") == SM_ID
557 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
558 assert shared_sm.description
is not None
559 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
560 assert len(get_result.get(
"displayName", {})) == 0
563 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
564 sm_data = json.loads(sm_data_string)
565 client.shells.put_submodel_by_id_aas_repository(shell_id, sm_id, sm_data)
568 if client.submodels
is None:
569 pytest.skip(
"Submodels API is not available in this client")
571 sm = model.Submodel(SM_ID)
572 sm.id_short = shared_sm.id_short
574 description_text =
"Put description for unit tests"
575 sm.description = model.MultiLanguageTextType({
"en": description_text})
577 sm_data_string = json.dumps(sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
578 sm_data = json.loads(sm_data_string)
582 if client.encoded_ids:
583 sm_id = encoder.encode_base_64(SM_ID)
585 result = client.submodels.put_submodels_by_id(sm_id, sm_data)
587 assert result
is True
589 get_result = client.submodels.get_submodel_by_id(sm_id)
590 assert get_result
is not None
591 assert get_result.get(
"idShort",
"") == shared_sm.id_short
592 assert get_result.get(
"id",
"") == SM_ID
594 assert get_result.get(
"description", {})[0].get(
"text",
"") == description_text
595 assert shared_sm.description
is not None
596 assert get_result.get(
"description", {})[0].get(
"text",
"") != shared_sm.description.get(
"en",
"")
597 assert len(get_result.get(
"displayName", {})) == 0
600 sm_data_string = json.dumps(shared_sm, cls=basyx.aas.adapter.json.AASToJsonEncoder)
601 sm_data = json.loads(sm_data_string)
602 client.submodels.put_submodels_by_id(SM_ID, sm_data)
605 if client.submodels
is None:
606 pytest.skip(
"Submodels API is not available in this client")
610 if client.encoded_ids:
611 sm_id = encoder.encode_base_64(SM_ID)
613 submodel_elements = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
615 assert submodel_elements
is not None
616 assert len(submodel_elements.get(
"result", [])) == 0
619 if client.submodels
is None:
620 pytest.skip(
"Submodels API is not available in this client")
622 sme_data_string = json.dumps(shared_sme_string, cls=basyx.aas.adapter.json.AASToJsonEncoder)
623 sme_data = json.loads(sme_data_string)
627 if client.encoded_ids:
628 sm_id = encoder.encode_base_64(SM_ID)
630 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
632 assert result
is not None
633 assert result.get(
"idShort",
"") == shared_sme_string.id_short
634 assert shared_sme_string.description
is not None
635 assert shared_sme_string.display_name
is not None
636 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
637 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
638 assert result.get(
"value",
"") == shared_sme_string.value
640 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
641 assert get_result
is not None
643 assert len(get_result.get(
"result", [])) == 1
646 if client.submodels
is None:
647 pytest.skip(
"Submodels API is not available in this client")
649 sme_data_string = json.dumps(shared_sme_bool, cls=basyx.aas.adapter.json.AASToJsonEncoder)
650 sme_data = json.loads(sme_data_string)
654 if client.encoded_ids:
655 sm_id = encoder.encode_base_64(SM_ID)
657 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
659 assert result
is not None
660 assert result.get(
"idShort",
"") == shared_sme_bool.id_short
661 assert shared_sme_bool.description
is not None
662 assert shared_sme_bool.display_name
is not None
663 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
664 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
665 assert json.loads(result.get(
"value",
"").lower()) == shared_sme_bool.value
667 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
668 assert get_result
is not None
670 assert len(get_result.get(
"result", [])) == 2
673 if client.submodels
is None:
674 pytest.skip(
"Submodels API is not available in this client")
676 sme_data_string = json.dumps(shared_sme_int, cls=basyx.aas.adapter.json.AASToJsonEncoder)
677 sme_data = json.loads(sme_data_string)
681 if client.encoded_ids:
682 sm_id = encoder.encode_base_64(SM_ID)
684 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
686 assert result
is not None
687 assert result.get(
"idShort",
"") == shared_sme_int.id_short
688 assert shared_sme_int.description
is not None
689 assert shared_sme_int.display_name
is not None
690 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
691 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
692 assert int(result.get(
"value",
"")) == shared_sme_int.value
694 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
695 assert get_result
is not None
697 assert len(get_result.get(
"result", [])) == 3
700 if client.submodels
is None:
701 pytest.skip(
"Submodels API is not available in this client")
703 sme_data_string = json.dumps(shared_sme_float, cls=basyx.aas.adapter.json.AASToJsonEncoder)
704 sme_data = json.loads(sme_data_string)
708 if client.encoded_ids:
709 sm_id = encoder.encode_base_64(SM_ID)
711 result = client.submodels.post_submodel_element_submodel_repo(sm_id, sme_data)
713 assert result
is not None
714 assert result.get(
"idShort",
"") == shared_sme_float.id_short
715 assert shared_sme_float.description
is not None
716 assert shared_sme_float.display_name
is not None
717 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
718 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
719 assert float(result.get(
"value",
"")) == shared_sme_float.value
721 get_result = client.submodels.get_all_submodel_elements_submodel_repository(sm_id)
722 assert get_result
is not None
724 assert len(get_result.get(
"result", [])) == 4
727 if client.submodels
is None:
728 pytest.skip(
"Submodels API is not available in this client")
732 if client.encoded_ids:
733 sm_id = encoder.encode_base_64(SM_ID)
735 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
737 assert result
is not None
738 assert result.get(
"idShort",
"") == shared_sme_string.id_short
739 assert shared_sme_string.description
is not None
740 assert shared_sme_string.display_name
is not None
741 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
742 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
743 assert result.get(
"value",
"") == shared_sme_string.value
746 if client.submodels
is None:
747 pytest.skip(
"Submodels API is not available in this client")
751 if client.encoded_ids:
752 sm_id = encoder.encode_base_64(SM_ID)
754 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
756 assert result
is not None
757 assert result.get(
"idShort",
"") == shared_sme_bool.id_short
758 assert shared_sme_bool.description
is not None
759 assert shared_sme_bool.display_name
is not None
760 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
761 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
762 assert json.loads(result.get(
"value",
"").lower()) == shared_sme_bool.value
765 if client.submodels
is None:
766 pytest.skip(
"Submodels API is not available in this client")
770 if client.encoded_ids:
771 sm_id = encoder.encode_base_64(SM_ID)
773 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
775 assert result
is not None
776 assert result.get(
"idShort",
"") == shared_sme_int.id_short
777 assert shared_sme_int.description
is not None
778 assert shared_sme_int.display_name
is not None
779 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
780 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
781 assert int(result.get(
"value",
"")) == shared_sme_int.value
784 if client.submodels
is None:
785 pytest.skip(
"Submodels API is not available in this client")
789 if client.encoded_ids:
790 sm_id = encoder.encode_base_64(SM_ID)
792 result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
794 assert result
is not None
795 assert result.get(
"idShort",
"") == shared_sme_float.id_short
796 assert shared_sme_float.description
is not None
797 assert shared_sme_float.display_name
is not None
798 assert result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
799 assert result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
800 assert float(result.get(
"value",
"")) == shared_sme_float.value
803 if client.submodels
is None:
804 pytest.skip(
"Submodels API is not available in this client")
806 new_value =
"Patched String Value"
810 if client.encoded_ids:
811 sm_id = encoder.encode_base_64(SM_ID)
813 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
814 assert submodel_element
is not None
816 old_value = submodel_element.get(
"value",
"")
818 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_string.id_short, new_value)
820 parsed = urlparse(client.base_url)
821 if parsed.port
in PYTHON_SERVER_PORTS:
823 assert result
is False
825 assert result
is True
827 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
829 assert get_result
is not None
830 assert get_result.get(
"idShort",
"") == shared_sme_string.id_short
831 assert get_result.get(
"value",
"") == new_value
832 assert shared_sme_string.description
is not None
833 assert shared_sme_string.display_name
is not None
834 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
835 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
836 assert get_result.get(
"value",
"") != old_value
839 if client.submodels
is None:
840 pytest.skip(
"Submodels API is not available in this client")
846 if client.encoded_ids:
847 sm_id = encoder.encode_base_64(SM_ID)
849 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
850 assert submodel_element
is not None
852 old_value = submodel_element.get(
"value",
"")
854 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_bool.id_short, new_value)
856 parsed = urlparse(client.base_url)
857 if parsed.port
in PYTHON_SERVER_PORTS:
859 assert result
is False
861 assert result
is True
863 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
865 assert get_result
is not None
866 assert get_result.get(
"idShort",
"") == shared_sme_bool.id_short
867 assert json.loads(get_result.get(
"value",
"").lower()) == json.loads(new_value)
868 assert shared_sme_bool.description
is not None
869 assert shared_sme_bool.display_name
is not None
870 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_bool.description.get(
"en",
"")
871 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_bool.display_name.get(
"en",
"")
872 assert get_result.get(
"value",
"").lower() != old_value.lower()
875 if client.submodels
is None:
876 pytest.skip(
"Submodels API is not available in this client")
882 if client.encoded_ids:
883 sm_id = encoder.encode_base_64(SM_ID)
885 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
886 assert submodel_element
is not None
888 old_value = submodel_element.get(
"value",
"")
890 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_int.id_short, new_value)
892 parsed = urlparse(client.base_url)
893 if parsed.port
in PYTHON_SERVER_PORTS:
895 assert result
is False
897 assert result
is True
899 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
901 assert get_result
is not None
902 assert get_result.get(
"idShort",
"") == shared_sme_int.id_short
903 assert int(get_result.get(
"value",
"")) == int(new_value)
904 assert shared_sme_int.description
is not None
905 assert shared_sme_int.display_name
is not None
906 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_int.description.get(
"en",
"")
907 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_int.display_name.get(
"en",
"")
908 assert int(get_result.get(
"value",
"")) != int(old_value)
911 if client.submodels
is None:
912 pytest.skip(
"Submodels API is not available in this client")
918 if client.encoded_ids:
919 sm_id = encoder.encode_base_64(SM_ID)
921 submodel_element = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
922 assert submodel_element
is not None
924 old_value = submodel_element.get(
"value",
"")
926 result = client.submodels.patch_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_float.id_short, new_value)
928 parsed = urlparse(client.base_url)
929 if parsed.port
in PYTHON_SERVER_PORTS:
931 assert result
is False
933 assert result
is True
935 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
937 assert get_result
is not None
938 assert get_result.get(
"idShort",
"") == shared_sme_float.id_short
939 assert float(get_result.get(
"value",
"")) == float(new_value)
940 assert shared_sme_float.description
is not None
941 assert shared_sme_float.display_name
is not None
942 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_float.description.get(
"en",
"")
943 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_float.display_name.get(
"en",
"")
944 assert float(get_result.get(
"value",
"")) != float(old_value)
947 if client.submodels
is None:
948 pytest.skip(
"Submodels API is not available in this client")
950 submodel_element_list = model.SubmodelElementList(id_short=
"sme_list_1", type_value_list_element=model.Property, value_type_list_element=model.datatypes.String)
951 submodel_element_list_dict = sdk_tools.convert_to_dict(submodel_element_list)
952 assert submodel_element_list_dict
is not None
956 if client.encoded_ids:
957 sm_id = encoder.encode_base_64(SM_ID)
959 post_list_element_result = client.submodels.post_submodel_element_submodel_repo(sm_id, submodel_element_list_dict)
961 assert post_list_element_result
is not None
963 property = model_builder.create_base_submodel_element_property(
None, model.datatypes.String,
"Value in List")
964 property_dict = sdk_tools.convert_to_dict(property)
965 assert property_dict
is not None
966 assert "idShort" not in property_dict
968 result = client.submodels.post_submodel_element_by_path_submodel_repo(sm_id, submodel_element_list.id_short, property_dict)
970 assert result
is not None
971 assert "idShort" not in result
973 submodel = client.submodels.get_submodel_by_id(sm_id)
975 assert submodel
is not None
976 elements = submodel.get(
"submodelElements", [])
977 assert len(elements) == 5
978 assert elements[4].get(
"idShort",
"") == submodel_element_list.id_short
979 list_elements = elements[4].get(
"value", [])
980 assert len(list_elements) == 1
981 assert list_elements[0].get(
"idShort",
"") ==
""
982 assert list_elements[0].get(
"value",
"") == property.value
986 if client.submodels
is None:
987 pytest.skip(
"Submodels API is not available in this client")
989 submodel_element_collection = model.SubmodelElementCollection(id_short=
"sme_collection_1")
990 submodel_element_collection_dict = sdk_tools.convert_to_dict(submodel_element_collection)
991 assert submodel_element_collection_dict
is not None
995 if client.encoded_ids:
996 sm_id = encoder.encode_base_64(SM_ID)
998 first_result = client.submodels.post_submodel_element_submodel_repo(sm_id, submodel_element_collection_dict)
1000 assert first_result
is not None
1002 property = model_builder.create_base_submodel_element_property(
"sme_property_in_collection", model.datatypes.String,
"Value in List")
1003 property_dict = sdk_tools.convert_to_dict(property)
1004 assert property_dict
is not None
1006 result = client.submodels.post_submodel_element_by_path_submodel_repo(sm_id, submodel_element_collection.id_short, property_dict)
1008 assert result
is not None
1009 assert result[
"idShort"] == property.id_short
1011 submodel = client.submodels.get_submodel_by_id(sm_id)
1013 assert submodel
is not None
1014 elements = submodel.get(
"submodelElements", [])
1015 assert len(elements) == 6
1016 assert elements[5].get(
"idShort",
"") == submodel_element_collection.id_short
1017 list_elements = elements[5].get(
"value", [])
1018 assert len(list_elements) == 1
1019 assert list_elements[0].get(
"idShort",
"") == property.id_short
1020 assert list_elements[0].get(
"value",
"") == property.value
1022 base_url: str = client.base_url
1023 new_client = create_by_url(base_url=base_url)
1024 assert new_client
is not None
1025 assert new_client.submodels
is not None
1027 sm = new_client.submodels.get_submodel_by_id(AIMC_SM_ID)
1030 decoded_id = encoder.encode_base_64(AIMC_SM_ID)
1031 decoded_sm = new_client.submodels.get_submodel_by_id(decoded_id)
1032 assert decoded_sm
is not None
1033 assert decoded_sm.get(
"id",
"") == AIMC_SM_ID
1036 base_url: str = client.base_url
1037 new_client = create_by_url(base_url=base_url)
1038 assert new_client
is not None
1039 assert new_client.shells
is not None
1041 sm = new_client.shells.get_asset_administration_shell_by_id(SHELL_ID)
1044 decoded_id = encoder.encode_base_64(SHELL_ID)
1045 decoded_sm = new_client.shells.get_asset_administration_shell_by_id(decoded_id)
1046 assert decoded_sm
is not None
1047 assert decoded_sm.get(
"id",
"") == SHELL_ID
1050 if client.experimental
is None:
1051 pytest.skip(
"Experimental API is not available in this client")
1053 if client.submodels
is None:
1054 pytest.skip(
"Submodels API is not available in this client")
1056 parsed = urlparse(client.base_url)
1057 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1064 if client.encoded_ids:
1065 sm_id = encoder.encode_base_64(SM_ID)
1067 file_sme = model.File(
"file_sme", content_type=
"application/pdf")
1068 file_post_result = client.submodels.post_submodel_element_submodel_repo(sm_id, sdk_tools.convert_to_dict(file_sme))
1069 assert file_post_result
is not None
1071 filename =
"https.pdf"
1072 file = Path(f
"./tests/test_data/{filename}").resolve()
1073 result = client.experimental.post_file_by_path_submodel_repo(sm_id, file_sme.id_short, file)
1074 assert result
is True
1076 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, file_sme.id_short)
1078 assert result_sme
is not None
1079 assert result_sme.get(
"idShort",
"") == file_sme.id_short
1080 assert result_sme.get(
"contentType",
"") == file_sme.content_type
1081 assert "value" in result_sme
1082 assert result_sme.get(
"value",
"") == f
"/{filename}"
1085 if client.experimental
is None:
1086 pytest.skip(
"Experimental API is not available in this client")
1088 parsed = urlparse(client.base_url)
1089 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1096 if client.encoded_ids:
1097 sm_id = encoder.encode_base_64(SM_ID)
1099 result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1100 assert result
is not None
1101 assert len(result) > 0
1102 assert result.startswith(b
"%PDF-1.7")
1105 if client.experimental
is None:
1106 pytest.skip(
"Experimental API is not available in this client")
1108 if client.submodels
is None:
1109 pytest.skip(
"Submodels API is not available in this client")
1111 parsed = urlparse(client.base_url)
1112 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1119 if client.encoded_ids:
1120 sm_id = encoder.encode_base_64(SM_ID)
1122 filename =
"aimc.json"
1123 file = Path(f
"./tests/test_data/{filename}").resolve()
1124 result = client.experimental.put_file_by_path_submodel_repo(sm_id,
"file_sme", file)
1125 assert result
is True
1127 get_result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1128 assert get_result
is not None
1129 assert len(get_result) > 0
1130 assert get_result.startswith(b
"{\n")
1132 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id,
"file_sme")
1133 assert result_sme
is not None
1134 assert "value" in result_sme
1135 assert result_sme.get(
"value",
"") == f
"/{filename}"
1138 if client.experimental
is None:
1139 pytest.skip(
"Experimental API is not available in this client")
1141 if client.submodels
is None:
1142 pytest.skip(
"Submodels API is not available in this client")
1144 parsed = urlparse(client.base_url)
1145 if parsed.port
in JAVA_SERVER_PORTS
or parsed.port
in PYTHON_SERVER_PORTS:
1151 if client.encoded_ids:
1152 sm_id = encoder.encode_base_64(SM_ID)
1154 result = client.experimental.delete_file_by_path_submodel_repo(sm_id,
"file_sme")
1155 assert result
is True
1157 get_result = client.experimental.get_file_by_path_submodel_repo(sm_id,
"file_sme")
1158 assert get_result
is None
1160 result_sme = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id,
"file_sme")
1161 assert result_sme
is not None
1162 assert "value" in result_sme
1163 assert result_sme.get(
"value",
"") ==
None
1166 if client.shells
is None:
1167 pytest.skip(
"Shells API is not available in this client")
1169 parsed = urlparse(client.base_url)
1170 if parsed.port
in PYTHON_SERVER_PORTS:
1176 if client.encoded_ids:
1177 shell_id = encoder.encode_base_64(SHELL_ID)
1179 result = client.shells.get_thumbnail_aas_repository(shell_id)
1180 assert result
is None
1183 if client.shells
is None:
1184 pytest.skip(
"Shells API is not available in this client")
1186 parsed = urlparse(client.base_url)
1187 if parsed.port
in PYTHON_SERVER_PORTS:
1193 if client.encoded_ids:
1194 shell_id = encoder.encode_base_64(SHELL_ID)
1196 filename =
"Pen_Machine.png"
1197 file = Path(f
"./tests/test_data/{filename}").resolve()
1199 result = client.shells.put_thumbnail_aas_repository(shell_id, file.name, file)
1200 assert result
is True
1203 if client.shells
is None:
1204 pytest.skip(
"Shells API is not available in this client")
1206 parsed = urlparse(client.base_url)
1207 if parsed.port
in PYTHON_SERVER_PORTS:
1213 if client.encoded_ids:
1214 shell_id = encoder.encode_base_64(SHELL_ID)
1216 result = client.shells.get_thumbnail_aas_repository(shell_id)
1217 assert result
is not None
1218 assert len(result) > 0
1219 assert result.startswith(b
"\x89PNG\r\n\x1a\n")
1222 if client.shells
is None:
1223 pytest.skip(
"Shells API is not available in this client")
1225 parsed = urlparse(client.base_url)
1226 if parsed.port
in PYTHON_SERVER_PORTS:
1232 if client.encoded_ids:
1233 shell_id = encoder.encode_base_64(SHELL_ID)
1235 result = client.shells.delete_thumbnail_aas_repository(shell_id)
1236 assert result
is True
1238 get_result = client.shells.get_thumbnail_aas_repository(shell_id)
1239 assert get_result
is None
1242 if client.shells
is None:
1243 pytest.skip(
"Shells API is not available in this client")
1247 if client.encoded_ids:
1248 shell_id = encoder.encode_base_64(SHELL_ID)
1250 result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1251 assert result
is not None
1252 references = result.get(
"result", [])
1253 assert len(references) == 1
1256 if client.shells
is None:
1257 pytest.skip(
"Shells API is not available in this client")
1261 if client.encoded_ids:
1262 shell_id = encoder.encode_base_64(SHELL_ID)
1266 temp_sml_ref = model.ModelReference.from_referable(model_builder.create_base_submodel(identifier=id, id_short=id_short))
1268 result = client.shells.post_submodel_reference_aas_repository(shell_id, sdk_tools.convert_to_dict(temp_sml_ref))
1270 assert result
is not None
1271 assert len(result.get(
"keys", [])) > 0
1272 key: dict = result.get(
"keys", [])[0]
1273 assert key.get(
"value",
"") == id
1274 assert key.get(
"type",
"") ==
"Submodel"
1276 check_result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1277 assert check_result
is not None
1278 check_references = check_result.get(
"result", [])
1279 assert len(check_references) == 2
1282 if client.shells
is None:
1283 pytest.skip(
"Submodels API is not available in this client")
1286 sm_id =
"temp_sm_id"
1288 if client.encoded_ids:
1289 shell_id = encoder.encode_base_64(SHELL_ID)
1290 sm_id = encoder.encode_base_64(sm_id)
1292 result = client.shells.delete_submodel_reference_by_id_aas_repository(shell_id, sm_id)
1294 assert result
is True
1296 get_result = client.shells.get_all_submodel_references_aas_repository(shell_id)
1297 assert get_result
is not None
1298 references = get_result.get(
"result", [])
1299 assert len(references) == 1
1302 if client.submodels
is None:
1303 pytest.skip(
"Submodels API is not available in this client")
1307 if client.encoded_ids:
1308 sm_id = encoder.encode_base_64(SM_ID)
1310 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1311 assert get_result
is not None
1312 old_value = get_result.get(
"value",
"")
1314 new_value =
"New Value via PUT"
1316 sme_data_string = json.dumps(shared_sme_string, cls=basyx.aas.adapter.json.AASToJsonEncoder)
1317 sme_data = json.loads(sme_data_string)
1318 sme_data[
"value"] = new_value
1320 result = client.submodels.put_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short, sme_data)
1322 assert result
is True
1324 get_result = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1326 assert get_result
is not None
1327 assert get_result.get(
"idShort",
"") == shared_sme_string.id_short
1328 assert get_result.get(
"value",
"") == new_value
1329 assert get_result.get(
"value",
"") != old_value
1330 assert shared_sme_string.description
is not None
1331 assert shared_sme_string.display_name
is not None
1332 assert get_result.get(
"description", {})[0].get(
"text",
"") == shared_sme_string.description.get(
"en",
"")
1333 assert get_result.get(
"displayName", {})[0].get(
"text",
"") == shared_sme_string.display_name.get(
"en",
"")
1336 sme_data[
"value"] =
"Sample String Value"
1337 result = client.submodels.put_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short, sme_data)
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 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_string.id_short)
1350 parsed = urlparse(client.base_url)
1351 if parsed.port
in PYTHON_SERVER_PORTS:
1353 assert value
is None
1356 assert value
is not None
1358 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1359 assert sm_data
is not None
1360 assert value == sm_data.get(
"value",
"")
1363 if client.submodels
is None:
1364 pytest.skip(
"Submodels API is not available in this client")
1368 if client.encoded_ids:
1369 sm_id = encoder.encode_base_64(SM_ID)
1371 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_int.id_short)
1373 parsed = urlparse(client.base_url)
1374 if parsed.port
in PYTHON_SERVER_PORTS:
1376 assert value
is None
1379 assert value
is not None
1381 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
1382 assert sm_data
is not None
1383 assert int(value) == int(sm_data.get(
"value",
""))
1386 if client.submodels
is None:
1387 pytest.skip(
"Submodels API is not available in this client")
1391 if client.encoded_ids:
1392 sm_id = encoder.encode_base_64(SM_ID)
1394 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_float.id_short)
1396 parsed = urlparse(client.base_url)
1397 if parsed.port
in PYTHON_SERVER_PORTS:
1399 assert value
is None
1402 assert value
is not None
1404 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
1405 assert sm_data
is not None
1406 assert float(value) == float(sm_data.get(
"value",
""))
1409 if client.submodels
is None:
1410 pytest.skip(
"Submodels API is not available in this client")
1414 if client.encoded_ids:
1415 sm_id = encoder.encode_base_64(SM_ID)
1417 value = client.submodels.get_submodel_element_by_path_value_only_submodel_repo(sm_id, shared_sme_bool.id_short)
1419 parsed = urlparse(client.base_url)
1420 if parsed.port
in PYTHON_SERVER_PORTS:
1422 assert value
is None
1425 assert value
is not None
1427 sm_data = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_bool.id_short)
1428 assert sm_data
is not None
1459 if client.submodels
is None:
1460 pytest.skip(
"Submodels API is not available in this client")
1464 if client.encoded_ids:
1465 sm_id = encoder.encode_base_64(SM_ID)
1467 response = client.submodels.get_submodel_by_id_value_only(sm_id)
1469 parsed = urlparse(client.base_url)
1470 if parsed.port
in PYTHON_SERVER_PORTS:
1472 assert response
is None
1474 elif parsed.port
in DOTNET_SERVER_PORTS:
1475 assert response
is not None
1476 value = response[shared_sm.id_short]
1478 assert response
is not None
1481 assert value
is not None
1482 assert len(value) > 5
1483 assert "sme_property_int" in value
1484 assert int(value[
"sme_property_int"]) == 263
1485 assert "sme_property_string" in value
1486 assert value[
"sme_property_string"] ==
"Sample String Value"
1487 assert "sme_property_float" in value
1488 assert float(value[
"sme_property_float"]) == 262.1
1491 if client.submodels
is None:
1492 pytest.skip(
"Submodels API is not available in this client")
1496 if client.encoded_ids:
1497 sm_id = encoder.encode_base_64(SM_ID)
1500 shared_sme_string.id_short: shared_sme_string.value,
1501 shared_sme_int.id_short: str(shared_sme_int.value),
1502 shared_sme_float.id_short: str(shared_sme_float.value)
1507 patch_dict = value_dict
1509 parsed = urlparse(client.base_url)
1510 if parsed.port
in PYTHON_SERVER_PORTS:
1514 if parsed.port
in JAVA_SERVER_PORTS:
1518 elif parsed.port
in DOTNET_SERVER_PORTS:
1519 patch_dict = value_dict
1521 result = client.submodels.patch_submodel_by_id_value_only(sm_id, patch_dict)
1523 assert result
is True
1525 string_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_string.id_short)
1526 int_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_int.id_short)
1527 float_prop_dict = client.submodels.get_submodel_element_by_path_submodel_repo(sm_id, shared_sme_float.id_short)
1529 assert string_prop_dict
is not None
1530 assert int_prop_dict
is not None
1531 assert float_prop_dict
is not None
1533 assert string_prop_dict.get(
"value",
"") == shared_sme_string.value
1534 assert int(int_prop_dict.get(
"value",
"")) == int(shared_sme_int.value)
1535 assert float(float_prop_dict.get(
"value",
"")) == float(shared_sme_float.value)
1539 if client.submodels
is None:
1540 pytest.skip(
"Submodels API is not available in this client")
1544 if client.encoded_ids:
1545 sm_id = encoder.encode_base_64(SM_ID)
1547 metadata = client.submodels.get_submodel_by_id_metadata(sm_id)
1548 assert metadata
is not None
1550 submodel = client.submodels.get_submodel_by_id(sm_id)
1551 assert submodel
is not None
1553 assert metadata.get(
"id",
"") == submodel.get(
"id",
"")
1554 assert metadata.get(
"idShort",
"") == submodel.get(
"idShort",
"")
1555 assert metadata.get(
"description", {})[0].get(
"text",
"") == submodel.get(
"description", {})[0].get(
"text",
"")
1556 if "displayName" in submodel
and submodel.get(
"displayName", []):
1557 assert metadata.get(
"displayName", {})[0].get(
"text",
"") == submodel.get(
"displayName", {})[0].get(
"text",
"")
1558 assert "submodelElements" not in metadata
1561 if client.shells
is None:
1562 pytest.skip(
"Shells API is not available in this client")
1566 if client.encoded_ids:
1567 shell_id = encoder.encode_base_64(SHELL_ID)
1569 result = client.shells.delete_asset_administration_shell_by_id(shell_id)
1571 assert result
is True
1573 get_result = client.shells.get_all_asset_administration_shells()
1574 assert get_result
is not None
1575 shells = get_result.get(
"result", [])
1576 assert len(shells) == 0
1579 if client.submodels
is None:
1580 pytest.skip(
"Submodels API is not available in this client")
1584 if client.encoded_ids:
1585 sm_id = encoder.encode_base_64(SM_ID)
1587 result = client.submodels.delete_submodel_by_id(sm_id)
1589 assert result
is True
1591 get_result = client.submodels.get_all_submodels()
1592 assert get_result
is not None
1593 submodels = get_result.get(
"result", [])
1594 assert len(submodels) == 1
1597 if client.submodels
is None:
1598 pytest.skip(
"Submodels API is not available in this client")
1602 if client.encoded_ids:
1603 sm_id = encoder.encode_base_64(AIMC_SM_ID)
1605 result = client.submodels.delete_submodel_by_id(sm_id)
1607 assert result
is True
1609 get_result = client.submodels.get_all_submodels()
1610 assert get_result
is not None
1611 submodels = get_result.get(
"result", [])
1612 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_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)