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

Cleaning up and refactoring test modules

parent e965283a
Branches
No related tags found
1 merge request!23Merge in Jack's changes
Pipeline #875 passed
......@@ -22,8 +22,8 @@ class pca(object):
>>> import os
>>> p = pca()
>>> p.importFolder(os.getcwd()+"\\tests\\pca_tests")
>>> p.setBaseline(os.getcwd()+"\\tests\\pca_tests\\sample_stl_sphere_BIN.stl")
>>> p.register(save=os.getcwd()+"\\tests\\pca_tests\\")
>>> p.setBaseline(os.getcwd()+stl_file_3.stl)
>stl_file_3.stlcwd()+"\\tests\\pca_tests\\")
>>> p.pca()
>>> sfs = [1, 2]
>>> newS = p.newShape(sfs)
......
from tests import *
\ No newline at end of file
from tests.util import get_path
\ No newline at end of file
File moved
......@@ -3,9 +3,9 @@ Testing suite for the core module
"""
import unittest
import os
import numpy as np
from random import randrange
from util import get_path
class TestCore(unittest.TestCase):
......@@ -13,10 +13,10 @@ class TestCore(unittest.TestCase):
def setUp(self):
"""Runs before each unit test.
Sets up the AmpObject object using "sample_stl_sphere_BIN.stl".
Sets up the AmpObject object using "stl_file.stl".
"""
from AmpScan.core import AmpObject
stl_path = self.get_path("sample_stl_sphere_BIN.stl")
stl_path = get_path("stl_file.stl")
self.amp = AmpObject(stl_path)
def test_centre(self):
......@@ -165,27 +165,3 @@ class TestCore(unittest.TestCase):
with self.assertRaises(ValueError):
self.amp.flip(3)
@staticmethod
def get_path(filename):
"""Returns the absolute path to a test file
Parameters
----------
filename : string
Name of file in tests to get path to
Returns
-------
stl_path : string
The path to the file
"""
# Check if the parent directory is tests (this is for Pycharm unittests)
if os.path.basename(os.getcwd()) == "tests":
# This is for Pycharm testing
stl_path = filename
else:
# This is for the Gitlab testing
stl_path = os.path.abspath(os.getcwd()) + "\\tests\\"+filename
return stl_path
......@@ -3,19 +3,17 @@ Testing suite for the core module
"""
import unittest
import os
import numpy as np
from random import randrange
from util import get_path
class TestCore(unittest.TestCase):
class TestRegistration(unittest.TestCase):
ACCURACY = 5 # The number of decimal places to value accuracy for - needed due to floating point inaccuracies
def setUp(self):
"""Runs before each unit test.
Sets up the AmpObject object using "sample_stl_sphere_BIN.stl".
Sets up the AmpObject object using "stl_file.stl".
"""
from AmpScan.core import AmpObject
stl_path = self.get_path("sample_stl_sphere_BIN.stl")
stl_path = get_path("stl_file.stl")
self.amp = AmpObject(stl_path)
......@@ -2,17 +2,17 @@
Testing suite for trim module
"""
import unittest
import os
from util import get_path
class TestTrim(unittest.TestCase):
def setUp(self):
"""Runs before each unit test
Sets up the AmpObject object using "sample_stl_sphere_BIN.stl"
Sets up the AmpObject object using "stl_file.stl"
"""
from AmpScan.core import AmpObject
stl_path = self.get_path("sample_stl_sphere_BIN.stl")
stl_path = get_path("stl_file.stl")
self.amp = AmpObject(stl_path)
def test_trim(self):
......@@ -28,27 +28,3 @@ class TestTrim(unittest.TestCase):
self.amp.planarTrim(0.6, plane=0.9)
with self.assertRaises(TypeError):
self.amp.planarTrim([], plane=[])
@staticmethod
def get_path(filename):
"""Returns the absolute path to a test file
Parameters
----------
filename : string
Name of file in tests to get path to
Returns
-------
stl_path : string
The path to the file
"""
# Check if the parent directory is tests (this is for Pycharm unittests)
if os.path.basename(os.getcwd()) == "tests":
# This is for Pycharm testing
stl_path = filename
else:
# This is for the Gitlab testing
stl_path = os.path.abspath(os.getcwd()) + "\\tests\\"+filename
return stl_path
"""
Common test utilities
"""
import os
def get_path(filename):
"""Returns the absolute path to a test file
Parameters
----------
filename : string
Name of file in tests to get path to
Returns
-------
stl_path : string
The path to the file
"""
# Check if the parent directory is tests (this is for Pycharm unittests)
if os.path.basename(os.getcwd()) == "tests":
# This is for Pycharm testing
stl_path = filename
else:
# This is for the Gitlab testing
stl_path = os.path.join(os.path.abspath(os.getcwd()), "tests", filename)
return stl_path
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment