|
32 | 32 | from ansys.geometry.core.designer import Component, Design |
33 | 33 | from ansys.geometry.core.designer.design import DesignFileFormat |
34 | 34 | from ansys.geometry.core.math import UNITVECTOR3D_Z, Plane, Point2D, Point3D, UnitVector3D, Vector3D |
35 | | -from ansys.geometry.core.misc import UNITS, Distance |
| 35 | +from ansys.geometry.core.misc import UNITS, Distance, ImportOptions |
36 | 36 | from ansys.geometry.core.sketch import Sketch |
37 | 37 | from ansys.geometry.core.tools.unsupported import ExportIdData, PersistentIdType |
38 | 38 |
|
@@ -588,7 +588,6 @@ def test_import_scdocx_with_external_docs(modeler: Modeler): |
588 | 588 | assert len(component.bodies) == 1 |
589 | 589 |
|
590 | 590 |
|
591 | | -@pytest.mark.skip(reason="Temporary skip for build promotion") |
592 | 591 | def test_named_selections_after_file_insert(modeler: Modeler): |
593 | 592 | """Test to verify named selections are imported during inserting a file.""" |
594 | 593 | # Create a new design |
@@ -666,3 +665,57 @@ def test_named_selections_after_file_open(modeler: Modeler): |
666 | 665 | assert set(actual_named_selections) == set(expected_named_selections), ( |
667 | 666 | f"Expected named selections {expected_named_selections}, but got {actual_named_selections}." |
668 | 667 | ) |
| 668 | + |
| 669 | + |
| 670 | +def test_file_insert_import_named_selections_post_import(modeler: Modeler): |
| 671 | + """Test to verify named selections can be imported after inserting a file.""" |
| 672 | + # Create a new design |
| 673 | + design = modeler.create_design("BugFix_1277429") |
| 674 | + |
| 675 | + # Verify initial named selections count |
| 676 | + initial_named_selections_count = len(design.named_selections) |
| 677 | + assert initial_named_selections_count == 0, ( |
| 678 | + f"Expected no named selections initially, but got {initial_named_selections_count}." |
| 679 | + ) |
| 680 | + |
| 681 | + # Insert the file |
| 682 | + file_path = Path(FILES_DIR, "reactorWNS.scdocx") |
| 683 | + options = ImportOptions() |
| 684 | + options.import_named_selections = False |
| 685 | + design.insert_file(file_path, import_options=options) |
| 686 | + |
| 687 | + # Verify initial named selections count |
| 688 | + initial_named_selections_count = len(design.named_selections) |
| 689 | + assert initial_named_selections_count == 0, ( |
| 690 | + f"Expected no named selections initially, but got {initial_named_selections_count}." |
| 691 | + ) |
| 692 | + design.components[0].import_named_selections() |
| 693 | + # Verify named selections count after importing |
| 694 | + updated_named_selections_count = len(design.named_selections) |
| 695 | + assert updated_named_selections_count == 9, ( |
| 696 | + f"Expected 9 named selections after file insertion, but got " |
| 697 | + f"{updated_named_selections_count}." |
| 698 | + ) |
| 699 | + |
| 700 | + # Expected named selections |
| 701 | + expected_named_selections = [ |
| 702 | + "wall_liquid_level", |
| 703 | + "wall_tank", |
| 704 | + "wall_probe_1", |
| 705 | + "wall_probe_2", |
| 706 | + "wall_shaft", |
| 707 | + "wall_impeller_1", |
| 708 | + "wall_shaft_1", |
| 709 | + "wall_impeller_2", |
| 710 | + "wall_shaft_2", |
| 711 | + ] |
| 712 | + |
| 713 | + # Verify the names of the named selections |
| 714 | + actual_named_selections = [ns.name for ns in design.named_selections] |
| 715 | + for ns_name in actual_named_selections: |
| 716 | + assert ns_name in expected_named_selections, f"Unexpected named selection: {ns_name}" |
| 717 | + |
| 718 | + # Verify all expected named selections are present |
| 719 | + assert set(actual_named_selections) == set(expected_named_selections), ( |
| 720 | + f"Expected named selections {expected_named_selections}, but got {actual_named_selections}." |
| 721 | + ) |
0 commit comments