예제 #1
0
    def test_temperature_sensor_f(self, mock_function):
        """Test temperature sensor."""
        from pmsensor import co2sensor
        client = mhz19.MHZClient(co2sensor, 'test.serial')
        sensor = mhz19.MHZ19Sensor(
            client, mhz19.SENSOR_TEMPERATURE, TEMP_FAHRENHEIT, 'name')
        sensor.update()

        self.assertEqual(75.2, sensor.state)
예제 #2
0
    def test_co2_sensor(self, mock_function):
        """Test CO2 sensor."""
        from pmsensor import co2sensor
        client = mhz19.MHZClient(co2sensor, 'test.serial')
        sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, 'name')
        sensor.update()

        self.assertEqual('name: CO2', sensor.name)
        self.assertEqual(1000, sensor.state)
        self.assertEqual('ppm', sensor.unit_of_measurement)
        self.assertTrue(sensor.should_poll)
        self.assertEqual({'temperature': 24}, sensor.device_state_attributes)
예제 #3
0
    def test_co2_sensor(self, mock_function):
        """Test CO2 sensor."""
        from pmsensor import co2sensor
        client = mhz19.MHZClient(co2sensor, 'test.serial')
        sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, 'name')
        sensor.update()

        assert 'name: CO2' == sensor.name
        assert 1000 == sensor.state
        assert 'ppm' == sensor.unit_of_measurement
        assert sensor.should_poll
        assert {'temperature': 24} == sensor.device_state_attributes
예제 #4
0
    def test_temperature_sensor(self, mock_function):
        """Test temperature sensor."""
        from pmsensor import co2sensor
        client = mhz19.MHZClient(co2sensor, 'test.serial')
        sensor = mhz19.MHZ19Sensor(
            client, mhz19.SENSOR_TEMPERATURE, None, 'name')
        sensor.update()

        assert 'name: Temperature' == sensor.name
        assert 24 == sensor.state
        assert '°C' == sensor.unit_of_measurement
        assert sensor.should_poll
        assert {'co2_concentration': 1000} == sensor.device_state_attributes
예제 #5
0
    def test_temperature_sensor(self, mock_function):
        """Test temperature sensor."""
        from pmsensor import co2sensor
        client = mhz19.MHZClient(co2sensor, 'test.serial')
        sensor = mhz19.MHZ19Sensor(
            client, mhz19.SENSOR_TEMPERATURE, None, 'name')
        sensor.update()

        self.assertEqual('name: Temperature', sensor.name)
        self.assertEqual(24, sensor.state)
        self.assertEqual('°C', sensor.unit_of_measurement)
        self.assertTrue(sensor.should_poll)
        self.assertEqual(
            {'co2_concentration': 1000}, sensor.device_state_attributes)
예제 #6
0
 def aiohttp_client_update_good_read(self, mock_function):
     """Test MHZClient when ppm is too high."""
     from pmsensor import co2sensor
     client = mhz19.MHZClient(co2sensor, 'test.serial')
     client.update()
     self.assertEqual({'temperature': 24, 'co2': 1000}, client.data)
예제 #7
0
 def aiohttp_client_update_ppm_overflow(self, mock_function):
     """Test MHZClient when ppm is too high."""
     from pmsensor import co2sensor
     client = mhz19.MHZClient(co2sensor, 'test.serial')
     client.update()
     self.assertIsNone(client.data.get('co2'))
예제 #8
0
 def aiohttp_client_update_oserror(self, mock_function):
     """Test MHZClient when library throws OSError."""
     from pmsensor import co2sensor
     client = mhz19.MHZClient(co2sensor, 'test.serial')
     client.update()
     self.assertEqual({}, client.data)