Simplified test suite
This commit is contained in:
parent
eb5c9c3fee
commit
3dc160d51f
4 changed files with 28 additions and 81 deletions
|
|
@ -1,70 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from openflexure_microscope.camera.pi import StreamingCamera
|
||||
from openflexure_stage import OpenFlexureStage
|
||||
from openflexure_microscope import Microscope
|
||||
|
||||
import os
|
||||
import io
|
||||
import sys
|
||||
import time
|
||||
import numpy as np
|
||||
import uuid
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import unittest
|
||||
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):
|
||||
|
||||
def test_movement(self):
|
||||
move_distance = 500
|
||||
for axis in range(3):
|
||||
for direction in [1, -1]:
|
||||
pos_i = microscope.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)
|
||||
|
||||
pos_f = microscope.stage.position
|
||||
diff = np.subtract(pos_f, pos_i)
|
||||
logging.debug("{} > {}".format(pos_i, pos_f))
|
||||
|
||||
self.assertTrue(np.array_equal(diff, move))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with StreamingCamera() as camera, OpenFlexureStage("/dev/ttyUSB0") as stage:
|
||||
|
||||
microscope = Microscope(camera, stage)
|
||||
|
||||
suites = [
|
||||
unittest.TestLoader().loadTestsFromTestCase(TestMicroscope),
|
||||
]
|
||||
|
||||
alltests = unittest.TestSuite(suites)
|
||||
|
||||
result = unittest.TextTestRunner(verbosity=2).run(alltests)
|
||||
|
||||
if result.wasSuccessful():
|
||||
print(success_string)
|
||||
|
||||
microscope.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue