Simplified test suite

This commit is contained in:
Joel Collins 2019-01-08 16:29:34 +00:00
parent eb5c9c3fee
commit 3dc160d51f
4 changed files with 28 additions and 81 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python
from openflexure_microscope.camera.pi import StreamingCamera, CaptureObject
import os
import io
import sys
@ -15,16 +16,6 @@ from pprint import pprint
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
success_string = """
/O
| |
_____) \\
(__0) \\______
(____0)
(____0) EVERYTHING IS OK!
(__o)___________
"""
class TestCaptureMethods(unittest.TestCase):
@ -291,27 +282,15 @@ class TestThreadStarting(unittest.TestCase):
if __name__ == '__main__':
camera = StreamingCamera()
with StreamingCamera() as camera:
suites = [
unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods),
unittest.TestLoader().loadTestsFromTestCase(TestUnencodedMethods),
unittest.TestLoader().loadTestsFromTestCase(TestThreadStarting),
unittest.TestLoader().loadTestsFromTestCase(TestRecordMethods),
]
suites = [
unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods),
unittest.TestLoader().loadTestsFromTestCase(TestUnencodedMethods),
unittest.TestLoader().loadTestsFromTestCase(TestThreadStarting),
unittest.TestLoader().loadTestsFromTestCase(TestRecordMethods),
]
alltests = unittest.TestSuite(suites)
alltests = unittest.TestSuite(suites)
result = unittest.TextTestRunner(verbosity=2).run(alltests)
print("Objects created during tests:")
# Show us what was captured
for im in camera.images:
pprint(im.metadata)
for im in camera.videos:
pprint(im.metadata)
if result.wasSuccessful():
print(success_string)
camera.close()
result = unittest.TextTestRunner(verbosity=2).run(alltests)

View file

@ -10,15 +10,12 @@ import unittest
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
success_string = """
/O
| |
_____) \\
(__0) \\______
(____0)
(____0) EVERYTHING IS OK!
(__o)___________
"""
OPENFLEXURERC = {
'plugins': [
'openflexure_microscope.plugins.testing:Plugin'
]
}
class TestPluginMethods(unittest.TestCase):
@ -40,25 +37,13 @@ class TestPluginMethods(unittest.TestCase):
if __name__ == '__main__':
openflexurerc = {
'plugins': [
'openflexure_microscope.plugins.testing:Plugin'
]
}
with Microscope(StreamingCamera(), OpenFlexureStage("/dev/ttyUSB0"), OPENFLEXURERC) as microscope:
with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage:
suites = [
unittest.TestLoader().loadTestsFromTestCase(TestPluginMethods),
]
microscope = Microscope(camera, stage, openflexurerc)
alltests = unittest.TestSuite(suites)
suites = [
unittest.TestLoader().loadTestsFromTestCase(TestPluginMethods),
]
result = unittest.TextTestRunner(verbosity=2).run(alltests)
alltests = unittest.TestSuite(suites)
result = unittest.TextTestRunner(verbosity=2).run(alltests)
if result.wasSuccessful():
print(success_string)
microscope.close()

View file

@ -18,16 +18,6 @@ from pprint import pprint
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
success_string = """
/O
| |
_____) \\
(__0) \\______
(____0)
(____0) EVERYTHING IS OK!
(__o)___________
"""
class TestMicroscope(unittest.TestCase):
@ -35,16 +25,16 @@ class TestMicroscope(unittest.TestCase):
move_distance = 500
for axis in range(3):
for direction in [1, -1]:
pos_i = microscope.stage.position
pos_i = stage.position
logging.debug(pos_i)
logging.info("Moving axis {} by {}".format(axis, move_distance*direction))
move = [0, 0, 0]
move[axis] = move_distance*direction
microscope.stage.move_rel(move)
stage.move_rel(move)
pos_f = microscope.stage.position
pos_f = stage.position
diff = np.subtract(pos_f, pos_i)
logging.debug("{} > {}".format(pos_i, pos_f))
@ -52,9 +42,7 @@ class TestMicroscope(unittest.TestCase):
if __name__ == '__main__':
with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage:
microscope = Microscope(camera, stage)
with OpenFlexureStage("/dev/ttyUSB0") as stage:
suites = [
unittest.TestLoader().loadTestsFromTestCase(TestMicroscope),
@ -63,8 +51,3 @@ if __name__ == '__main__':
alltests = unittest.TestSuite(suites)
result = unittest.TextTestRunner(verbosity=2).run(alltests)
if result.wasSuccessful():
print(success_string)
microscope.close()