@@ -3416,3 +3416,48 @@ def test_get_body_bounding_box(modeler: Modeler):
3416
3416
assert center .x .m == 0
3417
3417
assert center .y .m == 0
3418
3418
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