Skip to content

Commit fa7d397

Browse files
RyanJWardpyansys-ci-botpre-commit-ci[bot]
authored
test: import named selection tests (#2138)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ca8fc7c commit fa7d397

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

doc/changelog.d/2138.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Import named selection tests

tests/_incompatible_tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ backends:
9999
- tests/integration/test_trimmed_geometry.py::test_trimmed_curve_line_rotate
100100
- tests/integration/test_trimmed_geometry.py::test_trimmed_curve_circle_translate
101101
- tests/integration/test_trimmed_geometry.py::test_trimmed_curve_circle_rotate
102+
# Bug fix included from 26.1 onwards
103+
- tests/integration/test_design_import.py::test_named_selections_after_file_insert
104+
- tests/integration/test_design_import.py::test_named_selections_after_file_open
102105

103106
- version: "24.2"
104107
incompatible_tests:
@@ -192,6 +195,9 @@ backends:
192195
- tests/integration/test_repair_tools.py::test_fix_extra_edge
193196
# Issues in log retrieval from server when empty log are solved from 25R1 onwards
194197
- tests/integration/test_client.py::test_client_get_service_logs
198+
# Bug fix included from 26.1 onwards
199+
- tests/integration/test_design_import.py::test_named_selections_after_file_insert
200+
- tests/integration/test_design_import.py::test_named_selections_after_file_open
195201

196202
- version: "25.1"
197203
incompatible_tests:
@@ -254,6 +260,9 @@ backends:
254260
- tests/integration/test_repair_tools.py::test_find_and_fix_short_edges_comprehensive
255261
- tests/integration/test_repair_tools.py::test_find_and_fix_split_edges_comprehensive
256262
- tests/integration/test_repair_tools.py::test_find_and_fix_extra_edges_comprehensive
263+
# Bug fix included from 26.1 onwards
264+
- tests/integration/test_design_import.py::test_named_selections_after_file_insert
265+
- tests/integration/test_design_import.py::test_named_selections_after_file_open
257266

258267
- version: "25.2"
259268
incompatible_tests:
@@ -280,3 +289,6 @@ backends:
280289
- tests/integration/test_repair_tools.py::test_find_small_faces
281290
- tests/integration/test_repair_tools.py::test_find_small_face_id
282291
- tests/integration/test_repair_tools.py::test_find_and_fix_missing_faces_angle_distance
292+
# Bug fix included from 26.1 onwards
293+
- tests/integration/test_design_import.py::test_named_selections_after_file_insert
294+
- tests/integration/test_design_import.py::test_named_selections_after_file_open

tests/integration/test_design_import.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,82 @@ def test_import_scdocx_with_external_docs(modeler: Modeler):
564564

565565
for component in design.components[0].components:
566566
assert len(component.bodies) == 1
567+
568+
569+
def test_named_selections_after_file_insert(modeler: Modeler):
570+
"""Test to verify named selections are imported during inserting a file."""
571+
# Create a new design
572+
design = modeler.create_design("BugFix_1277429")
573+
574+
# Verify initial named selections count
575+
initial_named_selections_count = len(design.named_selections)
576+
assert initial_named_selections_count == 0, (
577+
f"Expected no named selections initially, but got {initial_named_selections_count}."
578+
)
579+
580+
# Insert the file
581+
file_path = Path(FILES_DIR, "reactorWNS.scdocx")
582+
design.insert_file(file_path)
583+
584+
# Verify named selections count after file insertion
585+
updated_named_selections_count = len(design.named_selections)
586+
assert updated_named_selections_count == 9, (
587+
f"Expected 9 named selections after file insertion, but got "
588+
f"{updated_named_selections_count}."
589+
)
590+
591+
# Expected named selections
592+
expected_named_selections = [
593+
"wall_liquid_level",
594+
"wall_tank",
595+
"wall_probe_1",
596+
"wall_probe_2",
597+
"wall_shaft",
598+
"wall_impeller_1",
599+
"wall_shaft_1",
600+
"wall_impeller_2",
601+
"wall_shaft_2",
602+
]
603+
604+
# Verify the names of the named selections
605+
actual_named_selections = [ns.name for ns in design.named_selections]
606+
for ns_name in actual_named_selections:
607+
assert ns_name in expected_named_selections, f"Unexpected named selection: {ns_name}"
608+
609+
# Verify all expected named selections are present
610+
assert set(actual_named_selections) == set(expected_named_selections), (
611+
f"Expected named selections {expected_named_selections}, but got {actual_named_selections}."
612+
)
613+
614+
615+
def test_named_selections_after_file_open(modeler: Modeler):
616+
"""Test to verify named selections are imported during open a file."""
617+
# Open File
618+
file_path = Path(FILES_DIR, "reactorWNS.scdocx")
619+
design = modeler.open_file(file_path)
620+
621+
# Verify named selections count after file opening
622+
named_selection_count = len(design.named_selections)
623+
assert named_selection_count == 9, (
624+
f"Expected 9 named selections after file opening, but got {named_selection_count}."
625+
)
626+
# Expected named selections
627+
expected_named_selections = [
628+
"wall_liquid_level",
629+
"wall_tank",
630+
"wall_probe_1",
631+
"wall_probe_2",
632+
"wall_shaft",
633+
"wall_impeller_1",
634+
"wall_shaft_1",
635+
"wall_impeller_2",
636+
"wall_shaft_2",
637+
]
638+
# Verify the names of the named selections
639+
actual_named_selections = [ns.name for ns in design.named_selections]
640+
for ns_name in actual_named_selections:
641+
assert ns_name in expected_named_selections, f"Unexpected named selection: {ns_name}"
642+
# Verify all expected named selections are present
643+
assert set(actual_named_selections) == set(expected_named_selections), (
644+
f"Expected named selections {expected_named_selections}, but got {actual_named_selections}."
645+
)

0 commit comments

Comments
 (0)