Skip to content

Commit bfa184d

Browse files
RyanJWardpyansys-ci-botRobPasMue
authored
test: add more code coverage (#2096)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com>
1 parent 5196f26 commit bfa184d

File tree

4 files changed

+949
-1
lines changed

4 files changed

+949
-1
lines changed

doc/changelog.d/2096.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add more code coverage

tests/integration/test_design.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,3 +3416,48 @@ def test_get_body_bounding_box(modeler: Modeler):
34163416
assert center.x.m == 0
34173417
assert center.y.m == 0
34183418
assert center.z.m == 0.5
3419+
3420+
3421+
def test_extrude_faces_failure_log_to_file(modeler: Modeler):
3422+
"""Test that the failure to extrude faces logs the correct message to a file."""
3423+
# Create a design and body for testing
3424+
design = modeler.create_design("test_design")
3425+
body = design.extrude_sketch("test_body", Sketch().box(Point2D([0, 0]), 1, 1), 1)
3426+
3427+
# Call the method with invalid parameters to trigger failure
3428+
result = modeler.geometry_commands.extrude_faces(
3429+
faces=[body.faces[0]],
3430+
distance=-10.0, # Invalid distance to trigger failure
3431+
direction=UnitVector3D([0, 0, 1]),
3432+
)
3433+
# Assert the result is an empty list
3434+
assert result == []
3435+
3436+
result = modeler.geometry_commands.extrude_faces_up_to(
3437+
faces=[body.faces[0]],
3438+
up_to_selection=body.faces[0], # Using the same face as target to trigger failure
3439+
direction=UnitVector3D([0, 0, 1]),
3440+
seed_point=Point3D([0, 0, 0]),
3441+
)
3442+
# Assert the result is an empty list
3443+
assert result == []
3444+
3445+
3446+
def test_extrude_edges_missing_parameters(modeler: Modeler):
3447+
"""Test that extrude_edges raises a ValueError when required parameters are missing."""
3448+
# Create a design and body for testing
3449+
design = modeler.create_design("test_design")
3450+
body = design.extrude_sketch("test_body", Sketch().box(Point2D([0, 0]), 1, 1), 1)
3451+
3452+
# Test case: Missing both `from_face` and `from_point`/`direction`
3453+
with pytest.raises(
3454+
ValueError,
3455+
match="To extrude edges, either a face or a direction and point must be provided.",
3456+
):
3457+
modeler.geometry_commands.extrude_edges(
3458+
edges=[body.edges[0]], # Using the first edge of the body
3459+
distance=10.0,
3460+
from_face=None,
3461+
from_point=None,
3462+
direction=None,
3463+
)

0 commit comments

Comments
 (0)