def test_get_name(self): deck = Deck() slot = Slot() c = Container() deck.add(slot, 'A1', (0, 0, 0)) red = Well(properties={'radius': 5}) blue = Well(properties={'radius': 5}) c.add(red, "Red", (0, 0, 0)) c.add(blue, "Blue", (10, 0, 0)) slot.add(c) self.assertEqual(red.get_name(), 'Red')
def generate_deck(self): deck = Deck() slot = Slot() deck.add(slot, 'A1', (5, 10, 0)) c = Container() red = Well(properties={'radius': 5}) blue = Well(properties={'radius': 5}) c.add(red, "Red", (5, 5, 0)) c.add(blue, "Blue", (15, 5, 0)) slot.add(c, 'tube_rack') return deck
def test_coordinates(self): deck = Deck() slot = Slot() plate = self.generate_plate(wells=96, cols=8, spacing=(10, 15), offset=(5, 15), radius=5) deck.add(slot, 'B2', (100, 200, 0)) slot.add(plate) self.assertEqual(plate['A1'].coordinates(deck), (105, 215, 0))
def test_top_bottom(self): deck = Deck() slot = Slot() plate = self.generate_plate(wells=4, cols=2, spacing=(10, 10), offset=(0, 0), radius=5, height=10) deck.add(slot, 'A1', (0, 0, 0)) slot.add(plate) self.assertEqual(plate['A1'].bottom(10), (plate['A1'], Vector(5, 5, 10))) self.assertEqual(plate['A1'].top(10), (plate['A1'], Vector(5, 5, 20)))
def test_well_from_center(self): deck = Deck() slot = Slot() plate = self.generate_plate(wells=4, cols=2, spacing=(10, 10), offset=(0, 0), radius=5) deck.add(slot, 'A1', (0, 0, 0)) slot.add(plate) self.assertEqual(plate['B2'].center(), (5, 5, 0)) self.assertEqual(plate['B2'].from_center(x=0.0, y=0.0, z=0.0), (5, 5, 0)) self.assertEqual( plate['B2'].from_center(r=1.0, theta=math.pi / 2, h=0.0), (5.0, 10.0, 0.0))
def test_get_all_children(self): c1 = self.generate_plate(4, 2, (5, 5), (0, 0), 5) c2 = self.generate_plate(4, 2, (5, 5), (0, 0), 5) deck = Deck() deck.add(c1, "A1", (0, 0, 0)) deck.add(c2, "A2", (50, 50, 50)) self.assertEqual(len(deck.get_all_children()), 10)
def test_robot_pause_and_resume(self): self.robot.move_to((Deck(), (100, 0, 0))) self.robot.move_to((Deck(), (101, 0, 0))) self.assertEqual(len(self.robot._commands), 2) self.robot.pause() def _run(): self.robot.run(mode='live') thread = threading.Thread(target=_run) thread.start() self.robot.resume() thread.join(0.5) self.assertEquals(thread.is_alive(), False) self.assertEqual(len(self.robot._commands), 2) self.robot.clear() self.assertEqual(len(self.robot._commands), 0) self.robot.move_to((Deck(), (100, 0, 0))) self.robot.move_to((Deck(), (101, 0, 0))) def _run(): self.robot.run(mode='live') self.robot.pause() thread = threading.Thread(target=_run) thread.start() thread.join(0.01) self.assertEquals(thread.is_alive(), True) self.assertEqual(len(self.robot._commands) > 0, True) self.robot.resume() thread.join(1) self.assertEqual(len(self.robot._commands), 2)
def test_max_dimensions(self): c1 = self.generate_plate(4, 2, (5, 5), (0, 0), 5) c2 = self.generate_plate(4, 2, (5, 5), (0, 0), 5) deck = Deck() deck.add(c1, "A1", (0, 0, 0)) deck.add(c2, "A2", (50, 50, 50)) actual = [(str(i), j) for i, j in deck.max_dimensions(deck)] expected = [('<Well A2>', (65.0, 60.0, 50.0)), ('<Well B1>', (60.0, 65.0, 50.0)), ('<Container A2>', (50.0, 50.0, 50.0))] self.assertListEqual(actual, expected)
def test_robot_move_to(self): self.robot.move_to((Deck(), (100, 0, 0))) self.robot.run(mode='live') position = self.robot._driver.get_head_position()['current'] self.assertEqual(position, (100, 0, 0))