def test_purify(self, mock_sleep, mock_serial, mock_writeAndWait, mock_pickUpNextTip, mock_mixByScript, mock_transferLiquid, mock_dumpTipToWaste, mock_uptakeLiquid, mock_moveAxisDelta): p = ponec.protocol(self.ber, self.settings) p.purify() p2 = ponec.protocol(self.ber, self.settings2) p2.purify()
def test_getAlreadyWaitedTime(self): p = ponec.protocol(self.ber, self.settings) p.timestamp = time.time() time.sleep(0.05) result = p.getAlreadyWaitedTime() self.assertTrue(result > 0.05) self.assertTrue(result < 0.07)
def test_purify__one_stage__pipette_speed(self, mock_setSpeedPipette, mock_sleep, mock_serial, mock_writeAndWait, mock_pickUpNextTip, mock_mixByScript, mock_transferLiquid, mock_dumpTipToWaste, mock_uptakeLiquid, mock_moveAxisDelta): p = ponec.protocol(self.ber, self.settings) p.purify() # Adding beads self.assertEqual(mock_setSpeedPipette.mock_calls[0], mock.call(1500.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[1], mock.call(2500.0)) # Removing sup self.assertEqual(mock_setSpeedPipette.mock_calls[2], mock.call(1500.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[3], mock.call(2500.0)) # Adding ethanol 1st stage self.assertEqual(mock_setSpeedPipette.mock_calls[4], mock.call(2000.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[5], mock.call(2500.0)) # Removing ethanol 1st stage self.assertEqual(mock_setSpeedPipette.mock_calls[6], mock.call(2000.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[7], mock.call(2500.0)) # Adding ethanol 2nd stage self.assertEqual(mock_setSpeedPipette.mock_calls[8], mock.call(2000.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[9], mock.call(2500.0)) # Removing ethanol 2nd stage self.assertEqual(mock_setSpeedPipette.mock_calls[10], mock.call(2000.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[11], mock.call(2500.0)) # Adding eluent self.assertEqual(mock_setSpeedPipette.mock_calls[12], mock.call(1800.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[13], mock.call(2500.0)) # Transferring eluate to the results tubes self.assertEqual(mock_setSpeedPipette.mock_calls[14], mock.call(1800.0)) self.assertEqual(mock_setSpeedPipette.mock_calls[15], mock.call(2500.0))
def test_getDelayBetweenActions(self): p = ponec.protocol(self.ber, self.settings) r = p.getDelayBetweenActions(100, 0) self.assertEqual(r, 100) r = p.getDelayBetweenActions(100, 1) self.assertEqual(r, 50) r = p.getDelayBetweenActions(100, -1) self.assertEqual(r, 100)
def test_transferLiquidManyTubes(self, mock_transferLiquid, mock_move, mock_dumpTipToWaste, mock_pickUpNextTip): p = ponec.protocol(self.ber, self.settings) p.transferLiquidManyTubes(sources=p.tubes.samples_list, destinations=p.tubes.result_list, v_list=self.settings.beads_vol_1st_stage_list) p.transferLiquidManyTubes(sources=p.tubes.samples_list, destinations=p.tubes.result_list)
def test_purify_two_stages(self, mock_absrobDNA, mock_transfer, mock_remsup, mock_etWash, mock_elution): p2 = ponec.protocol(self.ber, self.settings2) p2.purify() mock_transfer.assert_called() mock_absrobDNA.assert_called() mock_remsup.assert_called() mock_etWash.assert_called() mock_elution.assert_called()
def test_purify__one_stage__pipette_delay(self, mock_sleep, mock_serial, mock_writeAndWait, mock_pickUpNextTip, mock_mixByScript, mock_transferLiquid, mock_dumpTipToWaste, mock_uptakeLiquid, mock_moveAxisDelta): p = ponec.protocol(self.ber, self.settings) p.purify() for call in mock_transferLiquid.mock_calls: self.assertEqual(call[2]['delay'], 1.0)
def test__init_protocol(self): """ Check whether the protocol would even initialize """ p = ponec.protocol(self.ber, self.settings) self.assertEqual(p.robot, self.ber) self.assertEqual(p.settings, self.settings) self.assertEqual(p.tubes.samples_list[0].getVolume(), 100) self.assertEqual(p.default_pipette_speed, 2500.0) self.assertEqual(p.incubation_time, 0)
def test_incubate(self, mock_mixManySamples): p = ponec.protocol(self.ber, self.settings) p.timestamp = time.time() local_timestamp = time.time() time_to_wait = 0.05 p.incubation_time = time_to_wait p.incubate() time_waited = time.time() - local_timestamp self.assertTrue(time_waited > time_to_wait) self.assertTrue(time_waited < time_to_wait+0.2)
def test_transferSamplesToSecondStage(self, mock_pickUpTip, mock_dumpTip, mock_transferLiquid): self.assertEqual(self.settings2.V_beads_list, self.settings2.beads_vol_1st_stage_list) p2 = ponec.protocol(self.ber, self.settings2) self.assertEqual(p2.tubes.samples_list[0].getWell(), (1, 0)) p2.transferSamplesToSecondStage() self.assertEqual(self.settings2.V_beads_list, self.settings2.beads_vol_2nd_stage_list) self.assertEqual(p2.tubes.samples_list[0].getWell(), (1, 6))
def test_elution_incubation(self, mock_setSpeedPipette, mock_addEluentToAll, mock_mixManySamples, mock_pullBeads, mock_transferLiquidManyTubes): p = ponec.protocol(self.ber, self.settings) p.timestamp = time.time() local_timestamp = time.time() time_to_wait = 0.05 # Temporarily overwriting the setting p.settings.T_elute = time_to_wait p.elution() time_waited = time.time() - local_timestamp self.assertTrue(time_waited > time_to_wait) self.assertTrue(time_waited < time_to_wait+0.2) mock_mixManySamples.is_called()
def test_absorbDNAOntoBeads_incubation(self, mock_addBeads, mock_mixManySamples, mock_pullBeads): p = ponec.protocol(self.ber, self.settings) p.timestamp = time.time() local_timestamp = time.time() time_to_wait = 0.05 # Temporarily overwriting the setting p.settings.T_absorption = time_to_wait p.absorbDnaOntoBeads() time_waited = time.time() - local_timestamp self.assertTrue(time_waited > time_to_wait) self.assertTrue(time_waited < time_to_wait+0.2) mock_mixManySamples.is_called()
def test__reinitializeTubesForSecondCleanup(self): p = ponec.protocol(self.ber, self.settings2) p.settings.cleanups = 2 p.settings.positions_2nd_stage_tubes = p.settings.positionsToPurify2ndStage() p.tubes.intermediate_list = p.tubes.initIntermediate() p.tubes.result_column = 1 p.tubes.result_row = 6 p.tubes.result_list = p.tubes.initResults() self.assertEqual(p.settings.cleanups, 2) self.assertEqual(p.tubes.samples_list[0].getWell(), (1,0)) self.assertEqual(p.tubes.intermediate_list[0].getWell(), (1,3)) p._reinitializeTubesForSecondCleanup() self.assertEqual(p.tubes.samples_list[0].getWell(), (1,6)) self.assertEqual(p.tubes.intermediate_list[0].getWell(), (1,9)) self.assertEqual(p.tubes.result_list[0].getWell(), (0,0))
def test_mixManySamples(self, mock_mix, mock_pickUpNextTip, mock_dumpTipToWaste, mock_moveAxisDelta, mock_move): p = ponec.protocol(self.ber, self.settings) p.mixManySamples() for call, expected_sample in zip(mock_mix.mock_calls, p.tubes.samples_list): self.assertEqual(call[1][0], expected_sample)
def test_moveToSafe(self, mock_move): p = ponec.protocol(self.ber, self.settings) p.moveToSafe() mock_move.assert_called_with(z=self.settings.z_safe)
def test_removeSupernatant(self, mock_transferLiquid, mock_move, mock_dumpTipToWaste, mock_pickUpNextTip): p = ponec.protocol(self.ber, self.settings) p.removeSupernatant()