Skip to content
Snippets Groups Projects
Commit 2ce1d57b authored by jack-parsons's avatar jack-parsons
Browse files

Beefing up rotation test

parent ccf7f33a
No related branches found
No related tags found
1 merge request!23Merge in Jack's changes
Pipeline #850 passed
......@@ -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)
......
......@@ -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):
"""
......
import unittest
import os
import sys
import core_tests
import basic_tests
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment