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() assert client.data.get("co2") is None
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() assert {"temperature": 24, "co2": 1000} == client.data
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() assert {} == client.data
async def test_temperature_sensor_f(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, TEMP_FAHRENHEIT, "name") sensor.update() assert sensor.state == 75.2
async def test_temperature_sensor_f(mock_function, hass): """Test temperature sensor.""" with patch.object(hass.config.units, "temperature_unit", TEMP_FAHRENHEIT): client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0]) sensor.hass = hass sensor.update() assert sensor.state == 75
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() assert 75.2 == sensor.state
async def test_temperature_sensor(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None, "name") sensor.update() assert sensor.name == "name: Temperature" assert sensor.state == 24 assert sensor.unit_of_measurement == TEMP_CELSIUS assert sensor.should_poll assert sensor.device_state_attributes == {"co2_concentration": 1000}
async def test_co2_sensor(mock_function): """Test CO2 sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name") sensor.update() assert sensor.name == "name: CO2" assert sensor.state == 1000 assert sensor.unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION assert sensor.should_poll assert sensor.device_state_attributes == {"temperature": 24}
async def test_co2_sensor(mock_function, hass): """Test CO2 sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[1]) sensor.hass = hass sensor.update() assert sensor.name == "name: CO2" assert sensor.state == 1000 assert sensor.native_unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION assert sensor.should_poll assert sensor.extra_state_attributes == {"temperature": 24}
async def test_temperature_sensor(mock_function, hass): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0]) sensor.hass = hass sensor.update() assert sensor.name == "name: Temperature" assert sensor.state == 24 assert sensor.native_unit_of_measurement == TEMP_CELSIUS assert sensor.should_poll assert sensor.extra_state_attributes == {"co2_concentration": 1000}
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
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
async def aiohttp_client_update_oserror(mock_function): """Test MHZClient when library throws OSError.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {} == client.data