|
37 | 37 |
|
38 | 38 | import unittest |
39 | 39 | import unittest.mock |
| 40 | +from queue import Queue |
40 | 41 |
|
41 | 42 | import numpy |
42 | 43 |
|
43 | 44 | import microscope.testsuite.devices as dummies |
44 | 45 | import microscope.testsuite.mock_devices as mocks |
45 | 46 | from microscope import simulators |
| 47 | +from microscope.simulators.stage_aware_camera import StageAwareCamera |
46 | 48 |
|
47 | 49 |
|
48 | 50 | class TestSerialMock(unittest.TestCase): |
@@ -423,20 +425,20 @@ def setUp(self): |
423 | 425 |
|
424 | 426 | class TestImageGenerator(unittest.TestCase): |
425 | 427 | def test_non_square_patterns_shape(self): |
426 | | - # TODO: we should also be testing this via the camera but the |
427 | | - # TestCamera is only square. In the mean time, we only test |
428 | | - # directly the _ImageGenerator. |
429 | 428 | width = 16 |
430 | 429 | height = 32 |
431 | | - generator = simulators._ImageGenerator() |
432 | | - patterns = list(generator.get_methods()) |
433 | | - for i, pattern in enumerate(patterns): |
434 | | - with self.subTest(pattern): |
435 | | - generator.set_method(i) |
436 | | - array = generator.get_image(width, height, 0, 255) |
| 430 | + camera = simulators.SimulatedCamera(sensor_shape=(width, height)) |
| 431 | + buf = Queue() |
| 432 | + camera.set_client(buf) |
| 433 | + camera.enable() |
| 434 | + for idx, name in camera.describe_setting("image pattern")["values"]: |
| 435 | + with self.subTest(name): |
| 436 | + camera.set_setting("image pattern", idx) |
| 437 | + camera.trigger() |
| 438 | + image = buf.get() |
437 | 439 | # In matplotlib, an M-wide by N-tall image has M columns |
438 | 440 | # and N rows, so a shape of (N, M) |
439 | | - self.assertEqual(array.shape, (height, width)) |
| 441 | + self.assertEqual(image.shape, (height, width)) |
440 | 442 |
|
441 | 443 |
|
442 | 444 | class TestDummyController(unittest.TestCase, ControllerTests): |
|
0 commit comments