Beispiel #1
0
    def test_createEntry(self):
        repo = CsvDataRepository(self.TESTFILE, self.TESTFILECOLUMNS)
        repo.add(MeasureResult(25, 20))
        repo.add(MeasureResult(35, 30))

        f = open(self.TESTFILE, "r", newline="")
        lines = f.readlines()
        f.close()
        self.assertEqual(3, len(lines))
    def test_MeasureResult_with_params(self):
        mock_created_at = datetime.now()

        with mock.patch.object(MeasureResult,
                               'get_now',
                               return_value=mock_created_at):
            r = MeasureResult(21, 10)
            self.assertDictEqual(
                {
                    "value": 21,
                    "ambient": 10,
                    "created_at": mock_created_at
                }, r.__dict__)
 def test_title_by_temperature_alert_warm(self):
     rm = MeasureResult(TEMPERATURE_LIMITS.get('ALERT'), self.__AMBIENT)
     n = NotificationServiceFactory().getNotificationService(
         self.__typeMobile, rm)
     self.assertEqual('ACHTUNG! ZU WARME TEMPERATUR', n.get_title())
 def test_title_by_temperature_warning_cold(self):
     rm = MeasureResult(10, self.__AMBIENT)
     n = NotificationServiceFactory().getNotificationService(
         self.__typeMobile, rm)
     self.assertEqual('ACHTUNG! GERINGE TEMPERATUR', n.get_title())
 def test_title_by_temperature_information(self):
     rm = MeasureResult(TEMPERATURE_LIMITS.get('SETPOINT'), self.__AMBIENT)
     notificationService = NotificationServiceFactory(
     ).getNotificationService(self.__typeMobile, rm)
     self.assertEqual('INFORMATION', notificationService.get_title())
 def setUp(self):
     self.__AMBIENT = 30
     self.__measureResult = MeasureResult(10, self.__AMBIENT)
     self.__typeMobile = TELEGRAM
 def get_temperature_in_celsius(self) -> MeasureResult:
     water = self._get_temperature_in_celsius_by_sensor(self.sensor_id)
     reference_sensor = self._get_temperature_in_celsius_by_sensor(
         self.reference_sensor_id)
     return MeasureResult(water, reference_sensor)
Beispiel #8
0
 def test_runNotification(self):
     rm = MeasureResult(TEMPERATURE_LIMITS.get('ALERT'), -100)
     n = NotificationServiceFactory().getNotificationService(TELEGRAM, rm)
     n.notify()