Skip to content

Commit bbcee33

Browse files
syscordanpyansys-ci-botRobPasMue
authored
test: adding test for nurbs sketching (#2193)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 12a6feb commit bbcee33

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

doc/changelog.d/2193.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding test for nurbs sketching

tests/test_sketch.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
Slot,
4949
SpurGear,
5050
Triangle,
51+
nurbs,
5152
)
5253

5354
from .conftest import are_graphics_available
@@ -369,6 +370,33 @@ def test_sketch_nurbs():
369370
assert not sketch.edges[0].contains_point(Point2D([5, 5]))
370371

371372

373+
def test_sketch_nurbs_misc():
374+
"""Test NURBS Sketch for code coverage"""
375+
control_points = [
376+
Point2D([0.0, 0.0]),
377+
Point2D([1.0, 2.0]),
378+
Point2D([2.0, 0.0]),
379+
Point2D([3.0, 3.0]),
380+
]
381+
# Checking geomdl_nurbs_curve usage
382+
nurbs_curve = nurbs.SketchNurbs.fit_curve_from_points(points=control_points, degree=3)
383+
assert nurbs_curve.geomdl_nurbs_curve.ctrlpts[0][0] == 0.0
384+
# Checking value error for degrees less than 1
385+
with pytest.raises(
386+
ValueError,
387+
match="Degree must be at least 1",
388+
):
389+
nurbs.SketchNurbs.fit_curve_from_points(points=control_points, degree=0)
390+
# Checking Force linear interpolation
391+
control_points = [
392+
Point2D([0.0, 0.0]),
393+
Point2D([1.0, 1.0]),
394+
]
395+
nurbs_curve = nurbs.SketchNurbs.fit_curve_from_points(points=control_points)
396+
assert nurbs_curve.control_points[0].x == 0.0
397+
assert nurbs_curve.degree == 1
398+
399+
372400
def test_sketch_triangle_face():
373401
"""Test Triangle SketchFace sketching."""
374402
# Create a Sketch instance

0 commit comments

Comments
 (0)