From cceac83dae3568e8931d502a2dfa49f5757666b1 Mon Sep 17 00:00:00 2001 From: shimwell Date: Sun, 15 Dec 2024 01:53:42 +0100 Subject: [PATCH] added test for remove and names --- src/paramak/assemblies/assembly.py | 15 --------------- tests/test_assemblies/test_assembly.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tests/test_assemblies/test_assembly.py diff --git a/src/paramak/assemblies/assembly.py b/src/paramak/assemblies/assembly.py index f7bf0921..5e65b920 100644 --- a/src/paramak/assemblies/assembly.py +++ b/src/paramak/assemblies/assembly.py @@ -28,18 +28,3 @@ def names(self): for part in self: names.append(part[1].split('/')[-1]) return names - - - - -# testing -# sphere1 = cq.Workplane().moveTo(2, 2).sphere(1) -# box1 = cq.Workplane().box(1, 1, 1) -# assembly = Assembly() -# assembly.add(box1, name="box1", color=cq.Color(0.5, 0.5, 0.5)) -# assembly.add(sphere1, name="sphere") - - -# assembly2 = assembly.remove('sphere') -# assembly3 = assembly.remove('box1') -# assembly4 = assembly.remove('bosdfsdf') \ No newline at end of file diff --git a/tests/test_assemblies/test_assembly.py b/tests/test_assemblies/test_assembly.py new file mode 100644 index 00000000..b1581d70 --- /dev/null +++ b/tests/test_assemblies/test_assembly.py @@ -0,0 +1,20 @@ +import cadquery as cq +from paramak.assemblies.assembly import Assembly + +def test_remove_and_names(): + + sphere1 = cq.Workplane().moveTo(2, 2).sphere(1) + box1 = cq.Workplane().box(1, 1, 1) + assembly = Assembly() + assembly.add(box1, name="box1", color=cq.Color(0.5, 0.5, 0.5)) + assembly.add(sphere1, name="sphere") + + + assembly2 = assembly.remove('sphere') + assembly3 = assembly.remove('box1') + assembly4 = assembly.remove('bosdfsdf') + + assert assembly.names() == ['box1', 'sphere'] + assert assembly2.names() == ['box1'] + assert assembly3.names() == ['sphere'] + assert assembly4.names() == ['box1', 'sphere']