From 7435216469ad3930a73c752e5378ae89d3ac722e Mon Sep 17 00:00:00 2001
From: jack-parsons <jack.parsons.uk@icloud.com>
Date: Tue, 23 Jul 2019 16:25:31 +0100
Subject: [PATCH] Adding more tests to trim method

---
 .gitlab-ci.yml     | 2 +-
 AmpScan/trim.py    | 2 +-
 tests/test_trim.py | 9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6faf7a0..d025494 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,2 +1,2 @@
 tests:
-    script: python -m unittest -v
+    script: python -m -v unittest discover tests
diff --git a/AmpScan/trim.py b/AmpScan/trim.py
index f48e659..7bc61a2 100644
--- a/AmpScan/trim.py
+++ b/AmpScan/trim.py
@@ -31,7 +31,7 @@ class trimMixin(object):
         >>> amp.planarTrim(100, 2)
 
         """
-        if isinstance(height, Number):
+        if isinstance(height, Number) and isinstance(plane, int):
             # planar values for each vert on face 
             fv = self.vert[self.faces, plane]
             # Number points on each face are above cut plane
diff --git a/tests/test_trim.py b/tests/test_trim.py
index abf9f4a..74759cd 100644
--- a/tests/test_trim.py
+++ b/tests/test_trim.py
@@ -17,6 +17,15 @@ class TestTrim(unittest.TestCase):
 
     def test_trim(self):
         """Tests the trim method of AmpObject"""
+
+        # Testing that the method runs
+        self.amp.planarTrim(0.6, plane=2)
+
+        # Testing invalid data types raise TypeErrors
+        with self.assertRaises(TypeError):
+            self.amp.planarTrim(0.6, plane=[])
+        with self.assertRaises(TypeError):
+            self.amp.planarTrim(0.6, plane=0.9)
         with self.assertRaises(TypeError):
             self.amp.planarTrim([], plane=[])
 
-- 
GitLab