def test_should_write_1_when_on(self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() my_mock_serial.write.assert_called_with("1")
def test_should_write_a_1_when_already_off_and_on_requested(self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.stop_dripping() drip_governor.start_dripping() my_mock_serial.write.assert_called_with("1")
def test_should_be_able_to_toggle_on_and_off(self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() drip_governor.stop_dripping() drip_governor.start_dripping() my_mock_serial.write.assert_called_with("1")
def test_should_write_a_1_when_already_off_and_on_requested( self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.stop_dripping() drip_governor.start_dripping() my_mock_serial.write.assert_called_with("1")
def test_should_not_write_a_1_when_already_on(self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() self.assertEqual(1, my_mock_serial.write.call_count, "Setup failed") drip_governor.start_dripping() self.assertEqual(1, my_mock_serial.write.call_count)
def test_should_call_on_periodically(self, mock_Serial): drip_governor = DripGovernor('COM4', 10) my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() time.sleep(0.011) drip_governor.start_dripping() self.assertEqual(2, my_mock_serial.write.call_count)
def test_should_write_a_0_when_already_on_and_off_requested(self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() self.assertEqual(1, my_mock_serial.write.call_count, "Setup failed") drip_governor.stop_dripping() my_mock_serial.write.assert_called_with("0")
def test_should_write_a_0_when_already_on_and_off_requested( self, mock_Serial): drip_governor = DripGovernor('COM4') my_mock_serial = mock_Serial.return_value drip_governor.start_dripping() self.assertEqual(1, my_mock_serial.write.call_count, "Setup failed") drip_governor.stop_dripping() my_mock_serial.write.assert_called_with("0")
if current_frame_num == current_cue.end_frame: if TRACE: print('reached end of current cue') # If we're in a LOOP_UNTIL_HEIGHT cue, see if we should loop or continue onward current_height = float(drip_detector.num_drips) / tuning_collection.drips_per_height if (current_cue.cue_type == cue_file_mod.CueTypes.LOOP_UNTIL_HEIGHT and current_height < current_cue.until_height): if TRACE: print('relooping current cue back to frame %d' % (current_cue.start_frame,)) # Loop back to the start of this cue current_frame_num = current_cue.start_frame wave_pos = frame_position_cache[current_frame_num] wave_file.setpos(wave_pos) log.info("Waiting for drips") if drip_governor: drip_governor.start_dripping() else: if (current_cue.cue_type == cue_file_mod.CueTypes.LOOP_UNTIL_HEIGHT and current_height > current_cue.until_height): # log.warning("Dripping Too Fast Current: %s Cue: %s ahead by: %.2f" % (current_height, current_cue.until_height, (current_height - current_cue.until_height))) ahead_by_mm = current_height - current_cue.until_height ahead_by_drips = int(ahead_by_mm * tuning_collection.drips_per_height) log.warning('Too fast: '+'-' * ahead_by_drips + "> %d drips ahead" % ahead_by_drips) if drip_governor: if ahead_by_drips > 10: drip_governor.stop_dripping() print('------Stop Dripping!-----') elif ahead_by_drips < 5: drip_governor.start_dripping() print('+++++Start Dripping!+++++') # Advance to next cue current_cue_index += 1