test_entity_ids.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright 2021-2025 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. from taipy.core._entity._entity_ids import _EntityIds
  12. class TestEntityIds:
  13. def test_add_two_entity_ids(self):
  14. entity_ids_1 = _EntityIds()
  15. entity_ids_2 = _EntityIds()
  16. entity_ids_1_address = id(entity_ids_1)
  17. entity_ids_1.data_node_ids.update(["data_node_id_1", "data_node_id_2"])
  18. entity_ids_1.task_ids.update(["task_id_1", "task_id_2"])
  19. entity_ids_1.job_ids.update(["job_id_1", "job_id_2"])
  20. entity_ids_1.sequence_ids.update(["sequence_id_1", "sequence_id_2"])
  21. entity_ids_1.scenario_ids.update(["scenario_id_1", "scenario_id_2"])
  22. entity_ids_1.cycle_ids.update(["cycle_id_1", "cycle_id_2"])
  23. entity_ids_2.data_node_ids.update(["data_node_id_2", "data_node_id_3"])
  24. entity_ids_2.task_ids.update(["task_id_2", "task_id_3"])
  25. entity_ids_2.job_ids.update(["job_id_2", "job_id_3"])
  26. entity_ids_2.sequence_ids.update(["sequence_id_2", "sequence_id_3"])
  27. entity_ids_2.scenario_ids.update(["scenario_id_2", "scenario_id_3"])
  28. entity_ids_2.cycle_ids.update(["cycle_id_2", "cycle_id_3"])
  29. entity_ids_1 += entity_ids_2
  30. # += operator should not change the address of entity_ids_1
  31. assert id(entity_ids_1) == entity_ids_1_address
  32. assert entity_ids_1.data_node_ids == {"data_node_id_1", "data_node_id_2", "data_node_id_3"}
  33. assert entity_ids_1.task_ids == {"task_id_1", "task_id_2", "task_id_3"}
  34. assert entity_ids_1.job_ids == {"job_id_1", "job_id_2", "job_id_3"}
  35. assert entity_ids_1.sequence_ids == {"sequence_id_1", "sequence_id_2", "sequence_id_3"}
  36. assert entity_ids_1.scenario_ids == {"scenario_id_1", "scenario_id_2", "scenario_id_3"}
  37. assert entity_ids_1.cycle_ids == {"cycle_id_1", "cycle_id_2", "cycle_id_3"}