diff --git a/tests/basic_tests.py b/tests/basic_tests.py index 43db51fa58fd69458f99b50087ca19e0f8875b52..86d6cbdb5bc82cda0e8290d92f35cc6499e82f98 100644 --- a/tests/basic_tests.py +++ b/tests/basic_tests.py @@ -16,6 +16,7 @@ def suite(): class TestBasicFunction(unittest.TestCase): def test_setup(self): + """Tests that the path can be obtained""" modPath = os.path.abspath(os.getcwd()) sys.path.insert(0, modPath) diff --git a/tests/core_tests.py b/tests/core_tests.py index 2007ed5868f392927543ffb3318ec1029379a68e..4af62efb5d9472b273d64a89b82523e12cd291dc 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -4,6 +4,7 @@ Testing suite for the core functionality import unittest import os +import numpy as np def suite(): @@ -14,11 +15,12 @@ def suite(): class TestCore(unittest.TestCase): - ACCURACY = 5 # The number of decimal places to value accuracy for + ACCURACY = 5 # The number of decimal places to value accuracy for - needed due to floating point inaccuracies def setUp(self): """ - Set up the AmpObject object from "sample_stl_sphere_BIN.stl" + Runs before each unit test + Sets up the AmpObject object using "sample_stl_sphere_BIN.stl" """ from AmpScan.core import AmpObject stl_path = self.get_path("sample_stl_sphere_BIN.stl") @@ -42,11 +44,22 @@ class TestCore(unittest.TestCase): """ Tests the rotate method of AmpObject """ - s = str(type(self.amp)) - self.assertEqual(s, "<class 'AmpScan.core.AmpObject'>", "Not expected Object") + + # Test rotation on first node + rot = [np.pi/2, -np.pi/4, np.pi/3] + before_vert_pos = self.amp.vert[0][:] + self.amp.rotateAng(rot) + after_vert_pos = self.amp.vert[0][:] + np.dot(before_vert_pos, rot) + self.assertAlmostEqual(before_vert_pos, after_vert_pos, TestCore.ACCURACY) + + # Check single floats cause TypeError with self.assertRaises(TypeError): self.amp.rotateAng(7) - self.amp.rotateAng({}) + + # Check dictionaries cause TypeError + with self.assertRaises(TypeError): + self.amp.rotateAng(dict()) def test_translate(self): """ diff --git a/tests/sample_test.py b/tests/sample_test.py index cf44400d1a68657eaa36524eee73a0191c83c385..e6846aaf9fa33706eaedebec0aae7a8fd9e3a9fc 100644 --- a/tests/sample_test.py +++ b/tests/sample_test.py @@ -1,6 +1,4 @@ import unittest -import os -import sys import core_tests import basic_tests