def test_speed_change(model, monkeypatch): pipette = model.instrument._instrument robot = model.robot robot._driver.simulating = False from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] def write_with_log(command, ack, connection, timeout, tag=None): if 'G0F' in command: command_log.append(command.strip()) elif 'M114' in command: return 'ok MCS: X:0.00 Y:0.00 Z:0.00 A:0.00 B:0.00 C:0.00' return driver_3_0.SMOOTHIE_ACK monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) pipette.tip_attached = True pipette.max_volume = 100 pipette.set_speed(aspirate=20, dispense=40) pipette.aspirate(10) pipette.dispense(10) expected = [ ['G0F1200'], # pipette's default aspirate speed in mm/min ['G0F24000'], ['G0F2400'], # pipette's default dispense speed in mm/min ['G0F24000'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_disable_motor(smoothie, monkeypatch): from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] smoothie.simulating = False def write_with_log(command, ack, connection, timeout, tag=None): command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK def _parse_position_response(arg): return smoothie.position monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) monkeypatch.setattr(driver_3_0, '_parse_position_response', _parse_position_response) smoothie.disengage_axis('X') smoothie.disengage_axis('XYZ') smoothie.disengage_axis('ABCD') expected = [ ['M18X'], ['M400'], ['M18[XYZ]+'], ['M400'], ['M18[ABC]+'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_distribute_air_gap_and_disposal_vol(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.distribute( 60, plate[2], plate[0:2], air_gap=20, disposal_vol=20 ) expected = [ ['distributing', '60'], ['transferring', '60'], ['pick'], ['aspirating', '140', 'Well C1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well A1'], ['dispensing', '60', 'Well A1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well B1'], ['dispensing', '60', 'Well B1'], ['blow', 'Well A1'], ['drop'] ] fuzzy_assert(robot.commands(), expected=expected ) robot.clear_commands()
def test_speed_change(robot, instruments, monkeypatch): ulmm = { "aspirate": [[100, 0, 0.5]], "dispense": [[100, 0, 0.5]] } pipette = instruments.Pipette(mount='right', ul_per_mm=ulmm) robot._driver.simulating = False command_log = [] def write_with_log(command, ack, connection, timeout, tag=None): if 'G0F' in command: command_log.append(command.strip()) elif 'M114' in command: return 'ok MCS: X:0.00 Y:0.00 Z:0.00 A:0.00 B:0.00 C:0.00' return driver_3_0.SMOOTHIE_ACK monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) pipette.tip_attached = True pipette.max_volume = 100 pipette._working_volume = 100 pipette.set_speed(aspirate=20, dispense=40) pipette.aspirate(10) pipette.dispense(10) expected = [ ['G0F1200'], # pipette's default aspirate speed in mm/min ['G0F24000'], ['G0F2400'], # pipette's default dispense speed in mm/min ['G0F24000'], ] fuzzy_assert(result=command_log, expected=expected)
def test_distribute_mix(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.distribute( 200, plate[0], plate[1:3], mix_before=(1, 10), mix_after=(1, 10) ) expected = [ ['distributing', '200'], ['transferring', '200'], ['pick'], ['mix', '10'], ['aspirating', 'Well A1'], ['dispensing'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well B1'], ['mix', '10'], ['aspirating', 'Well A1'], ['dispensing'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well C1'], ['drop'] ] fuzzy_assert(robot.commands(), expected=expected ) robot.clear_commands()
def test_max_speed_change(model, monkeypatch): robot = model.robot robot._driver.simulating = False from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] def write_with_log(command, ack, connection, timeout, tag=None): if 'M203.1' in command or 'G0F' in command: command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) robot.head_speed(555) robot.head_speed(x=1, y=2, z=3, a=4, b=5, c=6) robot.head_speed(123, x=7) robot._driver.push_speed() robot._driver.set_speed(321) robot._driver.pop_speed() expected = [ ['G0F{}'.format(555 * 60)], ['M203.1 A4 B5 C6 X1 Y2 Z3'], ['M203.1 X7'], ['G0F{}'.format(123 * 60)], ['G0F{}'.format(321 * 60)], ['G0F{}'.format(123 * 60)], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_distribute_air_gap_and_disposal_vol(self): self.p200.reset() self.p200.distribute( 60, self.plate[2], self.plate[0:2], air_gap=20, disposal_vol=20 ) expected = [ ['distributing', '60'], ['transferring', '60'], ['pick'], ['aspirating', '140', 'Well C1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well A1'], ['dispensing', '60', 'Well A1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well B1'], ['dispensing', '60', 'Well B1'], ['blow', 'Well A1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected ) self.robot.clear_commands()
def test_distribute_mix(self): self.p200.reset() self.p200.distribute( 200, self.plate[0], self.plate[1:3], mix_before=(1, 10), mix_after=(1, 10) ) expected = [ ['distributing', '200'], ['transferring', '200'], ['pick'], ['mix', '10'], ['aspirating', 'Well A1'], ['dispensing'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well B1'], ['mix', '10'], ['aspirating', 'Well A1'], ['dispensing'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well C1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected ) self.robot.clear_commands()
def test_set_active_current(smoothie, monkeypatch): from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] smoothie._setup() smoothie.home() smoothie.simulating = False def write_with_log(command, ack, connection, timeout, tag=None): command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK def _parse_position_response(arg): return smoothie.position monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) monkeypatch.setattr(driver_3_0, '_parse_position_response', _parse_position_response) smoothie.set_active_current({ 'X': 2, 'Y': 2, 'Z': 2, 'A': 2, 'B': 2, 'C': 2 }) smoothie.set_dwelling_current({ 'X': 0, 'Y': 0, 'Z': 0, 'A': 0, 'B': 0, 'C': 0 }) smoothie.move({'X': 0, 'Y': 0, 'Z': 0, 'A': 0, 'B': 0, 'C': 0}) smoothie.move({'B': 1, 'C': 1}) smoothie.set_active_current({'B': 0.42, 'C': 0.42}) smoothie.home('BC') expected = [ ['M907 A2 B2 C2 X2 Y2 Z2 G4P0.005 G0A0B0C0X0Y0Z0'], # move all ['M400'], ['M907 A2 B0 C0 X2 Y2 Z2 G4P0.005'], # disable BC axes ['M400'], ['M907 A0 B2 C2 X0 Y0 Z0 G4P0.005 G0B1.3C1.3 G0B1C1'], # move BC ['M400'], ['M907 A0 B0 C0 X0 Y0 Z0 G4P0.005'], # disable BC axes ['M400'], ['M907 A0 B0.42 C0.42 X0 Y0 Z0 G4P0.005 G28.2BC'], # home BC ['M400'], ['M907 A0 B0 C0 X0 Y0 Z0 G4P0.005'], # dwell all axes after home ['M400'], ['M114.2'], # update the position ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_transfer_single_channel(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.channels = 1 p200.transfer( 200, plate.cols('1', '2'), plate.cols('3'), touch_tip=False, blow_out=False, trash=False ) expected = [ ['Transferring', '200'], ['pick'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well A3'], ['aspirating', '200', 'Well B1'], ['dispensing', '200', 'Well A3'], ['aspirating', '200', 'Well C1'], ['dispensing', '200', 'Well B3'], ['aspirating', '200', 'Well D1'], ['dispensing', '200', 'Well B3'], ['aspirating', '200', 'Well E1'], ['dispensing', '200', 'Well C3'], ['aspirating', '200', 'Well F1'], ['dispensing', '200', 'Well C3'], ['aspirating', '200', 'Well G1'], ['dispensing', '200', 'Well D3'], ['aspirating', '200', 'Well H1'], ['dispensing', '200', 'Well D3'], ['aspirating', '200', 'Well A2'], ['dispensing', '200', 'Well E3'], ['aspirating', '200', 'Well B2'], ['dispensing', '200', 'Well E3'], ['aspirating', '200', 'Well C2'], ['dispensing', '200', 'Well F3'], ['aspirating', '200', 'Well D2'], ['dispensing', '200', 'Well F3'], ['aspirating', '200', 'Well E2'], ['dispensing', '200', 'Well G3'], ['aspirating', '200', 'Well F2'], ['dispensing', '200', 'Well G3'], ['aspirating', '200', 'Well G2'], ['dispensing', '200', 'Well H3'], ['aspirating', '200', 'Well H2'], ['dispensing', '200', 'Well H3'], ['return'], ['drop'] ] fuzzy_assert( robot.commands(), expected=expected ) robot.clear_commands()
def test_transfer_single_channel(self): self.p200.reset() self.p200.channels = 1 self.p200.transfer( 200, self.plate.cols('1', '2'), self.plate.cols('3'), touch_tip=False, blow_out=False, trash=False ) expected = [ ['Transferring', '200'], ['pick'], ['aspirating', '200', 'Well A1'], ['dispensing', '200', 'Well A3'], ['aspirating', '200', 'Well B1'], ['dispensing', '200', 'Well A3'], ['aspirating', '200', 'Well C1'], ['dispensing', '200', 'Well B3'], ['aspirating', '200', 'Well D1'], ['dispensing', '200', 'Well B3'], ['aspirating', '200', 'Well E1'], ['dispensing', '200', 'Well C3'], ['aspirating', '200', 'Well F1'], ['dispensing', '200', 'Well C3'], ['aspirating', '200', 'Well G1'], ['dispensing', '200', 'Well D3'], ['aspirating', '200', 'Well H1'], ['dispensing', '200', 'Well D3'], ['aspirating', '200', 'Well A2'], ['dispensing', '200', 'Well E3'], ['aspirating', '200', 'Well B2'], ['dispensing', '200', 'Well E3'], ['aspirating', '200', 'Well C2'], ['dispensing', '200', 'Well F3'], ['aspirating', '200', 'Well D2'], ['dispensing', '200', 'Well F3'], ['aspirating', '200', 'Well E2'], ['dispensing', '200', 'Well G3'], ['aspirating', '200', 'Well F2'], ['dispensing', '200', 'Well G3'], ['aspirating', '200', 'Well G2'], ['dispensing', '200', 'Well H3'], ['aspirating', '200', 'Well H2'], ['dispensing', '200', 'Well H3'], ['return'], ['drop'] ] fuzzy_assert( self.robot.commands(), expected=expected ) self.robot.clear_commands()
def test_transfer_air_gap(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.transfer(120, plate[0], plate[1], air_gap=20) expected = [['Transferring', '120'], ['pick'], ['aspirating', '120', 'Well A1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well B1'], ['dispensing', '120', 'Well B1'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_consolidate_air_gap(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.consolidate(60, plate[0:2], plate[2], air_gap=20) expected = [['consolidating', '60'], ['transferring', '60'], ['pick'], ['aspirating', '60', 'Well A1'], ['aspirating', '60', 'Well B1'], ['dispensing', '120', 'Well C1'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_transfer(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.transfer( 30, plate[0:8], plate[1:9], new_tip='always', air_gap=10, disposal_vol=20, # ignored by transfer touch_tip=True, blow_out=True, trash=True) expected = [['Transferring', '30'], ['pick'], ['aspirating', '30', 'Well A1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well B1'], ['dispensing', '30', 'Well B1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well B1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well C1'], ['dispensing', '30', 'Well C1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well C1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well D1'], ['dispensing', '30', 'Well D1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well D1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well E1'], ['dispensing', '30', 'Well E1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well E1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well F1'], ['dispensing', '30', 'Well F1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well F1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well G1'], ['dispensing', '30', 'Well G1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well G1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well H1'], ['dispensing', '30', 'Well H1'], ['touch'], ['blow'], ['drop'], ['pick'], ['aspirating', '30', 'Well H1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well A2'], ['dispensing', '30', 'Well A2'], ['touch'], ['blow'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() with pytest.raises(ValueError, match='air_gap.*'): p200.transfer(300, plate[0], plate[1], air_gap=300) with pytest.raises(ValueError, match='air_gap.*'): p200.transfer(300, plate[0], plate[1], air_gap=10000)
def test_transfer_multichannel(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.channels = 8 p200.transfer(200, plate.cols[0], plate.cols[1], touch_tip=False, blow_out=False, trash=False) expected = [['Transferring', '200'], ['pick'], ['aspirating', '200', 'wells A1...H1'], ['dispensing', '200', 'wells A2...H2'], ['return'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_set_acceleration(smoothie, monkeypatch): from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] smoothie._setup() smoothie.home() smoothie.simulating = False def write_with_log(command, ack, connection, timeout, tag=None): command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK def _parse_position_response(arg): return smoothie.position monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) monkeypatch.setattr(driver_3_0, '_parse_position_response', _parse_position_response) smoothie.set_acceleration({'X': 1, 'Y': 2, 'Z': 3, 'A': 4, 'B': 5, 'C': 6}) smoothie.push_acceleration() smoothie.pop_acceleration() smoothie.set_acceleration({ 'X': 10, 'Y': 20, 'Z': 30, 'A': 40, 'B': 50, 'C': 60 }) smoothie.pop_acceleration() expected = [ ['M204 S10000 A4 B5 C6 X1 Y2 Z3'], ['M400'], ['M204 S10000 A4 B5 C6 X1 Y2 Z3'], ['M400'], ['M204 S10000 A40 B50 C60 X10 Y20 Z30'], ['M400'], ['M204 S10000 A4 B5 C6 X1 Y2 Z3'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_dwell_and_activate_axes(smoothie, monkeypatch): from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] smoothie._setup() smoothie.simulating = False def write_with_log(command, ack, connection, timeout, tag=None): command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK def _parse_position_response(arg): return smoothie.position monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) monkeypatch.setattr(driver_3_0, '_parse_position_response', _parse_position_response) smoothie.activate_axes('X') smoothie._set_saved_current() smoothie.dwell_axes('X') smoothie._set_saved_current() smoothie.activate_axes('XYBC') smoothie._set_saved_current() smoothie.dwell_axes('XC') smoothie._set_saved_current() smoothie.dwell_axes('BCY') smoothie._set_saved_current() expected = [ ['M907 A0.1 B0.05 C0.05 X1.25 Y0.3 Z0.1 G4P0.005'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ['M907 A0.1 B0.5 C0.5 X1.25 Y1.25 Z0.1 G4P0.005'], ['M400'], ['M907 A0.1 B0.5 C0.05 X0.3 Y1.25 Z0.1 G4P0.005'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)
def test_consolidate_air_gap(self): self.p200.reset() self.p200.consolidate( 60, self.plate[0:2], self.plate[2], air_gap=20 ) expected = [ ['consolidating', '60'], ['transferring', '60'], ['pick'], ['aspirating', '60', 'Well A1'], ['aspirating', '60', 'Well B1'], ['dispensing', '120', 'Well C1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands()
def test_transfer_air_gap(self): self.p200.reset() self.p200.transfer( 120, self.plate[0], self.plate[1], air_gap=20 ) expected = [ ['Transferring', '120'], ['pick'], ['aspirating', '120', 'Well A1'], ['air gap'], ['aspirating', '20'], ['dispensing', '20', 'Well B1'], ['dispensing', '120', 'Well B1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands()
def test_transfer_multichannel(self): self.p200.reset() self.p200.channels = 8 self.p200.transfer( 200, self.plate.cols[0], self.plate.cols[1], touch_tip=False, blow_out=False, trash=False ) expected = [ ['Transferring', '200'], ['pick'], ['aspirating', '200', 'wells A1...H1'], ['dispensing', '200', 'wells A2...H2'], ['return'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected ) self.robot.clear_commands()
def test_divisible_locations(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.transfer(100, plate[0:4], plate[0:2]) expected = [['transferring', '100'], ['pick'], ['aspirating', '100', 'Well A1'], ['dispensing', '100', 'Well A1'], ['aspirating', '100', 'Well B1'], ['dispensing', '100', 'Well A1'], ['aspirating', '100', 'Well C1'], ['dispensing', '100', 'Well B1'], ['aspirating', '100', 'Well D1'], ['dispensing', '100', 'Well B1'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.consolidate(100, plate[0:4], plate[0:2]) expected = [['consolidating', '100'], ['transferring', '100'], ['pick'], ['aspirating', '100', 'Well A1'], ['aspirating', '100', 'Well B1'], ['dispensing', '200', 'Well A1'], ['aspirating', '100', 'Well C1'], ['aspirating', '100', 'Well D1'], ['dispensing', '200', 'Well B1'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.distribute(100, plate[0:2], plate[0:4], disposal_vol=0) expected = [['distributing', '100'], ['transferring', '100'], ['pick'], ['aspirating', '200', 'Well A1'], ['dispensing', '100', 'Well A1'], ['dispensing', '100', 'Well B1'], ['aspirating', '200', 'Well B1'], ['dispensing', '100', 'Well C1'], ['dispensing', '100', 'Well D1'], ['drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_consolidate(self): self.p200.reset() self.p200.consolidate( 30, self.plate[0:8], self.plate['A2'], new_tip='always' ) expected = [ ['Consolidating', '30'], ['Transferring', '30'], ['Pick'], ['Aspirating', '30', 'Well A1'], ['Aspirating', '30', 'Well B1'], ['Aspirating', '30', 'Well C1'], ['Aspirating', '30', 'Well D1'], ['Aspirating', '30', 'Well E1'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '180', 'Well A2'], ['Drop'], ['Pick'], ['Aspirating', '30', 'Well G1'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '60', 'Well A2'], ['Drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands() self.p200.reset() self.p200.tip_attached = True self.p200.consolidate( 30, self.plate[0:8], self.plate['A2'], new_tip='never' ) expected = [ ['Consolidating', '30'], ['Transferring', '30'], ['Aspirating', '30', 'Well A1'], ['Aspirating', '30', 'Well B1'], ['Aspirating', '30', 'Well C1'], ['Aspirating', '30', 'Well D1'], ['Aspirating', '30', 'Well E1'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '180', 'Well A2'], ['Aspirating', '30', 'Well G1'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '60', 'Well A2'], ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands() self.p200.reset() self.p200.consolidate( 30, self.plate, self.plate[0] ) total_aspirates = 0 for c in self.robot.commands(): if 'aspirating' in c.lower(): total_aspirates += 1 self.assertEqual(total_aspirates, 96) self.robot.clear_commands() self.p200.reset() self.p200.transfer( 30, self.plate[0:8], self.plate['A2'] ) expected = [ ['Transferring', '30'], ['Pick'], ['Aspirating', '30', 'Well A1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well B1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well C1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well D1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well E1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well G1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '30', 'Well A2'], ['Drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands()
def test_divisible_locations(self): self.p200.reset() self.p200.transfer( 100, self.plate[0:4], self.plate[0:2] ) expected = [ ['transferring', '100'], ['pick'], ['aspirating', '100', 'Well A1'], ['dispensing', '100', 'Well A1'], ['aspirating', '100', 'Well B1'], ['dispensing', '100', 'Well A1'], ['aspirating', '100', 'Well C1'], ['dispensing', '100', 'Well B1'], ['aspirating', '100', 'Well D1'], ['dispensing', '100', 'Well B1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands() self.p200.reset() self.p200.consolidate( 100, self.plate[0:4], self.plate[0:2] ) expected = [ ['consolidating', '100'], ['transferring', '100'], ['pick'], ['aspirating', '100', 'Well A1'], ['aspirating', '100', 'Well B1'], ['dispensing', '200', 'Well A1'], ['aspirating', '100', 'Well C1'], ['aspirating', '100', 'Well D1'], ['dispensing', '200', 'Well B1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected ) self.robot.clear_commands() self.p200.reset() self.p200.distribute( 100, self.plate[0:2], self.plate[0:4], disposal_vol=0 ) expected = [ ['distributing', '100'], ['transferring', '100'], ['pick'], ['aspirating', '200', 'Well A1'], ['dispensing', '100', 'Well A1'], ['dispensing', '100', 'Well B1'], ['aspirating', '200', 'Well B1'], ['dispensing', '100', 'Well C1'], ['dispensing', '100', 'Well D1'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected ) self.robot.clear_commands()
def test_consolidate(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() p200.consolidate(30, plate[0:8], plate['A2'], new_tip='always') expected = [['Consolidating', '30'], ['Transferring', '30'], ['Pick'], ['Aspirating', '30', 'Well A1'], ['Aspirating', '30', 'Well B1'], ['Aspirating', '30', 'Well C1'], ['Aspirating', '30', 'Well D1'], ['Aspirating', '30', 'Well E1'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '180', 'Well A2'], ['Drop'], ['Pick'], ['Aspirating', '30', 'Well G1'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '60', 'Well A2'], ['Drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.tip_attached = True p200.consolidate(30, plate[0:8], plate['A2'], new_tip='never') expected = [ ['Consolidating', '30'], ['Transferring', '30'], ['Aspirating', '30', 'Well A1'], ['Aspirating', '30', 'Well B1'], ['Aspirating', '30', 'Well C1'], ['Aspirating', '30', 'Well D1'], ['Aspirating', '30', 'Well E1'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '180', 'Well A2'], ['Aspirating', '30', 'Well G1'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '60', 'Well A2'], ] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.consolidate(30, plate, plate[0]) total_aspirates = 0 for c in robot.commands(): if 'aspirating' in c.lower(): total_aspirates += 1 assert total_aspirates == 96 robot.clear_commands() p200.reset() p200.transfer(30, plate[0:8], plate['A2']) expected = [['Transferring', '30'], ['Pick'], ['Aspirating', '30', 'Well A1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well B1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well C1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well D1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well E1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well F1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well G1'], ['Dispensing', '30', 'Well A2'], ['Aspirating', '30', 'Well H1'], ['Dispensing', '30', 'Well A2'], ['Drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_distribute(local_test_pipette, robot): trash, tiprack1, tiprack2, plate, p200 = local_test_pipette p200.reset() # Setting true instead of calling pick_up_tip because the test is # currently based on an exact command list. Should make this better. p200.distribute(30, plate[0], plate[1:9], new_tip='always') expected = [['Distributing', '30', 'well A1', 'wells B1...A2'], ['Transferring'], ['Picking up tip'], ['Aspirating', '190', 'well A1'], ['Dispensing', '30', 'well B1'], ['Dispensing', '30', 'well C1'], ['Dispensing', '30', 'well D1'], ['Dispensing', '30', 'well E1'], ['Dispensing', '30', 'well F1'], ['Dispensing', '30', 'well G1'], ['Blow', 'well A1'], ['Drop'], ['Pick'], ['Aspirating', '70', 'well A1'], ['Dispensing', '30', 'well H1'], ['Dispensing', '30', 'well A2'], ['Blow', 'well A1'], ['Drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.tip_attached = True p200.distribute(30, plate[0], plate[1:9], new_tip='never') expected = [['Distributing', '30', 'well A1', 'wells B1...A2'], ['Transferring'], ['Aspirating', '190', 'well A1'], ['Dispensing', '30', 'well B1'], ['Dispensing', '30', 'well C1'], ['Dispensing', '30', 'well D1'], ['Dispensing', '30', 'well E1'], ['Dispensing', '30', 'well F1'], ['Dispensing', '30', 'well G1'], ['Blow', 'well A1'], ['Aspirating', '70', 'well A1'], ['Dispensing', '30', 'well H1'], ['Dispensing', '30', 'well A2'], ['Blow', 'well A1']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands() p200.reset() p200.distribute(30, plate[0], plate) total_dispenses = 0 for c in robot.commands(): if 'dispensing' in c.lower(): total_dispenses += 1 assert total_dispenses == 96 robot.clear_commands() p200.reset() p200.transfer(30, plate[0], plate[1:9], trash=False) expected = [['Transferring', '30', 'well A1'], ['Pick'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well B1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well C1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well D1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well E1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well F1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well G1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well H1'], ['Aspirating', '30', 'well A1'], ['Dispensing', '30', 'well A2'], ['Return'], ['Drop']] fuzzy_assert(robot.commands(), expected=expected) robot.clear_commands()
def test_transfer(self): self.p200.reset() self.p200.transfer( 30, self.plate[0:8], self.plate[1:9], new_tip='always', air_gap=10, disposal_vol=20, # ignored by transfer touch_tip=True, blow_out=True, trash=True ) expected = [ ['Transferring', '30'], ['pick'], ['aspirating', '30', 'Well A1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well B1'], ['dispensing', '30', 'Well B1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well B1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well C1'], ['dispensing', '30', 'Well C1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well C1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well D1'], ['dispensing', '30', 'Well D1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well D1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well E1'], ['dispensing', '30', 'Well E1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well E1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well F1'], ['dispensing', '30', 'Well F1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well F1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well G1'], ['dispensing', '30', 'Well G1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well G1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well H1'], ['dispensing', '30', 'Well H1'], ['blow'], ['touch'], ['drop'], ['pick'], ['aspirating', '30', 'Well H1'], ['air'], ['aspirating', '10'], ['touch'], ['dispensing', '10', 'Well A2'], ['dispensing', '30', 'Well A2'], ['blow'], ['touch'], ['drop'] ] fuzzy_assert(self.robot.commands(), expected=expected) self.robot.clear_commands()
def test_plunger_commands(smoothie, monkeypatch): from opentrons.drivers import serial_communication from opentrons.drivers.smoothie_drivers import driver_3_0 command_log = [] smoothie._setup() smoothie.home() smoothie.simulating = False def write_with_log(command, ack, connection, timeout, tag=None): command_log.append(command.strip()) return driver_3_0.SMOOTHIE_ACK def _parse_position_response(arg): return smoothie.position monkeypatch.setattr(serial_communication, 'write_and_return', write_with_log) monkeypatch.setattr(driver_3_0, '_parse_position_response', _parse_position_response) smoothie.home() expected = [ ['M907 A0.8 B0.5 C0.5 X0.3 Y0.3 Z0.8 G4P0.005 G28.2.+[ABCZ].+'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ['M203.1 Y50'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.8 Z0.1 G4P0.005 G91 G0Y-28 G0Y10 G90'], ['M400'], ['M203.1 X80'], ['M400'], ['M907 A0.1 B0.05 C0.05 X1.25 Y0.3 Z0.1 G4P0.005 G28.2X'], ['M400'], ['M203.1 A125 B40 C40 X600 Y400 Z125'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ['M203.1 Y80'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y1.25 Z0.1 G4P0.005 G28.2Y'], ['M400'], ['M203.1 Y8'], ['M400'], ['G91 G0Y-3 G90'], ['M400'], ['G28.2Y'], ['M400'], ['G91 G0Y-3 G90'], ['M400'], ['M203.1 A125 B40 C40 X600 Y400 Z125'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ['M114.2'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected) command_log = [] smoothie.move({'X': 0, 'Y': 1.123456, 'Z': 2, 'A': 3}) expected = [ ['M907 A0.8 B0.05 C0.05 X1.25 Y1.25 Z0.8 G4P0.005 G0.+'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected) command_log = [] smoothie.move({'B': 2}) expected = [ ['M907 A0.1 B0.5 C0.05 X0.3 Y0.3 Z0.1 G4P0.005 G0B2'], ['M400'], ['M907 A0.1 B0.05 C0.05 X0.3 Y0.3 Z0.1 G4P0.005'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected) command_log = [] smoothie.move({ 'X': 10.987654321, 'Y': 1.12345678, 'Z': 2, 'A': 3, 'B': 4, 'C': 5 }) expected = [ # Set active axes high ['M907 A0.8 B0.5 C0.5 X1.25 Y1.25 Z0.8 G4P0.005 G0.+[BC].+'], ['M400'], # Set plunger current low ['M907 A0.8 B0.05 C0.05 X1.25 Y1.25 Z0.8 G4P0.005'], ['M400'], ] # from pprint import pprint # pprint(command_log) fuzzy_assert(result=command_log, expected=expected)