def test_drip_recorded_handler_adds_correct_height_per_drip(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 2.5
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm, starting_height)
        drip_message = DripRecordedMessage(1)

        sdza.drip_reported_handler(drip_message)

        self.assertEqual(0.4, sdza.current_z_location_mm())
Exemple #2
0
    def test_drip_recorded_handler_adds_correct_height_per_drip(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 2.5
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm,
                               starting_height)
        drip_message = DripRecordedMessage(1)

        sdza.drip_reported_handler(drip_message)

        self.assertEqual(0.4, sdza.current_z_location_mm())
    def test_reset_removes_drips_count_accounting_for_hardware(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 1.0
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm, starting_height)
        drip_message_1 = DripRecordedMessage(1)
        drip_message_2 = DripRecordedMessage(2)
        drip_message_3 = DripRecordedMessage(1)
        sdza.drip_reported_handler(drip_message_1)
        self.assertEqual(1.0, sdza.current_z_location_mm())
        sdza.drip_reported_handler(drip_message_2)
        self.assertEqual(2.0, sdza.current_z_location_mm())

        sdza.reset()
        self.assertEqual(0.0, sdza.current_z_location_mm())
        self.assertEqual(2, mock_communicatior.send.call_count)
        mock_communicatior.send.assert_called_with(SetDripCountMessage(0))

        sdza.drip_reported_handler(drip_message_3)
        self.assertEqual(1.0, sdza.current_z_location_mm())
    def test_drip_recorded_handler_adds_drips_if_missing_message(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 1.0
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm, starting_height)
        drip_message_1 = DripRecordedMessage(1)
        drip_message_2 = DripRecordedMessage(3)

        sdza.drip_reported_handler(drip_message_1)
        sdza.drip_reported_handler(drip_message_2)

        self.assertEqual(3.0, sdza.current_z_location_mm())
Exemple #5
0
    def test_reset_removes_drips_count_accounting_for_hardware(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 1.0
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm,
                               starting_height)
        drip_message_1 = DripRecordedMessage(1)
        drip_message_2 = DripRecordedMessage(2)
        drip_message_3 = DripRecordedMessage(1)
        sdza.drip_reported_handler(drip_message_1)
        self.assertEqual(1.0, sdza.current_z_location_mm())
        sdza.drip_reported_handler(drip_message_2)
        self.assertEqual(2.0, sdza.current_z_location_mm())

        sdza.reset()
        self.assertEqual(0.0, sdza.current_z_location_mm())
        self.assertEqual(2, mock_communicatior.send.call_count)
        mock_communicatior.send.assert_called_with(SetDripCountMessage(0))

        sdza.drip_reported_handler(drip_message_3)
        self.assertEqual(1.0, sdza.current_z_location_mm())
    def test_reset_removes_drips_count(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 2.5
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm, starting_height)
        drip_message = DripRecordedMessage(1)
        sdza.drip_reported_handler(drip_message)
        sdza.reset()
        actual_height = sdza.current_z_location_mm()
        history = sdza.drip_history

        self.assertEqual(0.0, actual_height)
        self.assertEqual([], history)
Exemple #7
0
    def test_drip_recorded_handler_adds_drips_if_missing_message(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 1.0
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm,
                               starting_height)
        drip_message_1 = DripRecordedMessage(1)
        drip_message_2 = DripRecordedMessage(3)

        sdza.drip_reported_handler(drip_message_1)
        sdza.drip_reported_handler(drip_message_2)

        self.assertEqual(3.0, sdza.current_z_location_mm())
Exemple #8
0
    def test_reset_removes_drips_count(self):
        mock_communicatior = MagicMock()
        starting_height = 0.0
        drips_per_mm = 2.5
        sdza = SerialDripZAxis(mock_communicatior, drips_per_mm,
                               starting_height)
        drip_message = DripRecordedMessage(1)
        sdza.drip_reported_handler(drip_message)
        sdza.reset()
        actual_height = sdza.current_z_location_mm()
        history = sdza.drip_history

        self.assertEqual(0.0, actual_height)
        self.assertEqual([], history)
 def test_init_sets_up_starting_height(self):
     mock_communicatior = MagicMock()
     starting_height = 10.0
     sdza = SerialDripZAxis(mock_communicatior, 1.0, starting_height)
     self.assertEqual(starting_height, sdza.current_z_location_mm())
Exemple #10
0
 def test_init_sets_up_starting_height(self):
     mock_communicatior = MagicMock()
     starting_height = 10.0
     sdza = SerialDripZAxis(mock_communicatior, 1.0, starting_height)
     self.assertEqual(starting_height, sdza.current_z_location_mm())