class TestHardwareStatusCollectorService(object):

    SAMPLE_CAPACITOR_VOLTAGE = 5 * 1000

    @mock.patch('drivers.microcontroller_driver.MicrocontrollerDriver.MicrocontrollerDriver', autospec = False)
    def setup(self, microcontroller_driver_mock):
        self._microcontroller_driver_mock_instance = microcontroller_driver_mock.return_value
        self._microcontroller_driver_mock_instance.get_capacitor_voltage.return_value = self.SAMPLE_CAPACITOR_VOLTAGE
        self._hardware_status_collector_service = HardwareStatusCollectorService(self._microcontroller_driver_mock_instance)

    def test_when_getting_capacitor_voltage_then_capacitor_voltage_is_returned(self):
        returned_capacitor_voltage = self._hardware_status_collector_service.get_capacitor_voltage()
        assert_equals(returned_capacitor_voltage, self.SAMPLE_CAPACITOR_VOLTAGE * HardwareStatusCollectorService.CAPACITOR_VOLTAGE_SCALE)

    def test_given_empty_capacitor_voltage_when_getting_capacitor_voltage_then_empty_capacitor_voltage_is_returned(self):
        self._microcontroller_driver_mock_instance.get_capacitor_voltage.return_value = None
        returned_capacitor_voltage = self._hardware_status_collector_service.get_capacitor_voltage()
        assert_equals(returned_capacitor_voltage, None)

    def test_when_getting_remaining_capacitory_energy_then_remaining_capacitor_energy_is_returned(self):
        returned_capacitor_energy = self._hardware_status_collector_service.get_remaining_capacitor_energy()
        assert_true(returned_capacitor_energy > 0)
 def setup(self, microcontroller_driver_mock):
     self._microcontroller_driver_mock_instance = microcontroller_driver_mock.return_value
     self._microcontroller_driver_mock_instance.get_capacitor_voltage.return_value = self.SAMPLE_CAPACITOR_VOLTAGE
     self._hardware_status_collector_service = HardwareStatusCollectorService(self._microcontroller_driver_mock_instance)