summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGemma Fardell <gfardell@stfc.ac.uk>2019-06-24 14:44:06 +0100
committerGemma Fardell <gfardell@stfc.ac.uk>2019-06-24 14:44:06 +0100
commit4235e71a4de64130228097907134f78bd9e22798 (patch)
tree4a293dbfc76429dcd2a24ad257a49105b30da77e
parentb49e77382db690ccacde93b7b947753b930f5458 (diff)
downloadframework-4235e71a4de64130228097907134f78bd9e22798.tar.gz
framework-4235e71a4de64130228097907134f78bd9e22798.tar.bz2
framework-4235e71a4de64130228097907134f78bd9e22798.tar.xz
framework-4235e71a4de64130228097907134f78bd9e22798.zip
Unit tests on test image loading and image size
-rwxr-xr-xWrappers/Python/test/test_TestData.py107
1 files changed, 69 insertions, 38 deletions
diff --git a/Wrappers/Python/test/test_TestData.py b/Wrappers/Python/test/test_TestData.py
index c4a0a70..fa0b98f 100755
--- a/Wrappers/Python/test/test_TestData.py
+++ b/Wrappers/Python/test/test_TestData.py
@@ -1,10 +1,9 @@
import numpy
from ccpi.framework import TestData
import os, sys
-
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from testclass import CCPiTestClass
-
+import unittest
class TestTestData(CCPiTestClass):
def test_random_noise(self):
@@ -17,67 +16,99 @@ class TestTestData(CCPiTestClass):
self.assertAlmostEqual(norm, 48.881268, places=4)
def test_load_CAMERA(self):
- loader = TestData()
- image = loader.load(TestData.CAMERA)
- if image:
- res = True
- else:
- res = False
+ loader = TestData()
+ res = False
+ try:
+ image = loader.load(TestData.CAMERA)
+ if (image.shape[0] == 512) and (image.shape[1] == 512):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)
+
def test_load_BOAT(self):
loader = TestData()
- image = loader.load(TestData.BOAT)
-
- if image:
- res = True
- else:
- res = False
+ res = False
+ try:
+ image = loader.load(TestData.BOAT)
+ if (image.shape[0] == 512) and (image.shape[1] == 512):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)
def test_load_PEPPERS(self):
loader = TestData()
- image = loader.load(TestData.PEPPERS)
-
- if image:
- res = True
- else:
- res = False
+ res = False
+ try:
+ image = loader.load(TestData.PEPPERS)
+ if (image.shape[0] == 512) and (image.shape[1] == 512) and (image.shape[2] == 3):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)
def test_load_RESOLUTION_CHART(self):
loader = TestData()
- image = loader.load(TestData.RESOLUTION_CHART)
-
- if image:
- res = True
- else:
- res = False
+ res = False
+ try:
+ image = loader.load(TestData.RESOLUTION_CHART)
+ if (image.shape[0] == 512) and (image.shape[1] == 512):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)
def test_load_SIMPLE_PHANTOM_2D(self):
loader = TestData()
- image = loader.load(TestData.SIMPLE_PHANTOM_2D)
-
- if image:
- res = True
- else:
- res = False
+ res = False
+ try:
+ image = loader.load(TestData.SIMPLE_PHANTOM_2D)
+ if (image.shape[0] == 512) and (image.shape[1] == 512):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)
def test_load_SHAPES(self):
loader = TestData()
- image = loader.load(TestData.SHAPES)
-
- if image:
- res = True
- else:
- res = False
+ res = False
+ try:
+ image = loader.load(TestData.SHAPES)
+ if (image.shape[0] == 200) and (image.shape[1] == 300):
+ res = True
+ else:
+ print("Image dimension mismatch")
+ except FileNotFoundError:
+ print("File not found")
+ except:
+ print("Failed to load file")
self.assertTrue(res)