Added capture resize to API unit test
This commit is contained in:
parent
8a4be49d46
commit
58d37354c3
2 changed files with 64 additions and 13 deletions
|
|
@ -36,23 +36,35 @@ class TestCapture(unittest.TestCase):
|
|||
connection = APIconnection(host="localhost", port=5000, api_ver="v1")
|
||||
resolution = connection.get_config()['video_resolution']
|
||||
|
||||
capture_array = connection.capture(
|
||||
use_video_port=True,
|
||||
keep_on_disk=False,
|
||||
delete_after_use=True)
|
||||
for resize in [None, (640, 480)]:
|
||||
|
||||
self.assertTrue(capture_array.shape == (resolution[1], resolution[0], 3))
|
||||
if resize:
|
||||
resolution = resize
|
||||
|
||||
capture_array = connection.capture(
|
||||
use_video_port=True,
|
||||
keep_on_disk=False,
|
||||
delete_after_use=True,
|
||||
resize=resize)
|
||||
|
||||
self.assertTrue(capture_array.shape == (resolution[1], resolution[0], 3))
|
||||
|
||||
def test_capture_full(self):
|
||||
connection = APIconnection(host="localhost", port=5000, api_ver="v1")
|
||||
resolution = connection.get_config()['image_resolution']
|
||||
|
||||
capture_array = connection.capture(
|
||||
use_video_port=False,
|
||||
keep_on_disk=False,
|
||||
delete_after_use=True)
|
||||
for resize in [None, (640, 480)]:
|
||||
|
||||
self.assertTrue(capture_array.shape == (resolution[1], resolution[0], 3))
|
||||
if resize:
|
||||
resolution = resize
|
||||
|
||||
capture_array = connection.capture(
|
||||
use_video_port=False,
|
||||
keep_on_disk=False,
|
||||
delete_after_use=True,
|
||||
resize=resize)
|
||||
|
||||
self.assertTrue(capture_array.shape == (resolution[1], resolution[0], 3))
|
||||
|
||||
class TestStage(unittest.TestCase):
|
||||
|
||||
|
|
@ -67,6 +79,41 @@ class TestStage(unittest.TestCase):
|
|||
for key in expected_keys:
|
||||
self.assertTrue(key in config)
|
||||
|
||||
def test_stage_state(self):
|
||||
connection = APIconnection(host="localhost", port=5000, api_ver="v1")
|
||||
state = connection.get_state()
|
||||
|
||||
self.assertTrue('stage' in state)
|
||||
|
||||
expected_keys = [
|
||||
'position',
|
||||
]
|
||||
|
||||
for key in expected_keys:
|
||||
self.assertTrue(key in state['stage'])
|
||||
|
||||
def test_movement(self):
|
||||
connection = APIconnection(host="localhost", port=5000, api_ver="v1")
|
||||
|
||||
move_distance = 500
|
||||
for axis in range(3):
|
||||
for direction in [1, -1]:
|
||||
pos_i_dict = connection.get_state()['stage']['position']
|
||||
pos_i = [pos_i_dict['x'], pos_i_dict['y'], pos_i_dict['z']]
|
||||
|
||||
move = [0, 0, 0]
|
||||
move[axis] = move_distance*direction
|
||||
|
||||
connection.move_by(*move)
|
||||
|
||||
pos_f_dict = connection.get_state()['stage']['position']
|
||||
pos_f = [pos_f_dict['x'], pos_f_dict['y'], pos_f_dict['z']]
|
||||
|
||||
diff = np.subtract(pos_f, pos_i)
|
||||
logging.debug("{} > {}".format(pos_i, pos_f))
|
||||
|
||||
self.assertTrue(np.array_equal(diff, move))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
suites = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue