def test_humidity_sensor(self): """Test humidity sensor.""" device = mock_device(10, "Family Room") location = mock_location("Home") data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.HUMIDITY, 50.4567)] sensor = CanarySensor(data, SensorType.HUMIDITY, location, device) sensor.update() self.assertEqual("Home Family Room Humidity", sensor.name) self.assertEqual("%", sensor.unit_of_measurement) self.assertEqual(50.5, sensor.state)
def test_fahrenheit_temperature_sensor(self): """Test temperature sensor with fahrenheit.""" device = mock_device(10, "Family Room") location = mock_location("Home", False) data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.TEMPERATURE, 21.1567)] sensor = CanarySensor(data, SensorType.TEMPERATURE, location, device) sensor.update() self.assertEqual("Home Family Room Temperature", sensor.name) self.assertEqual("°F", sensor.unit_of_measurement) self.assertEqual(21.2, sensor.state)
def test_celsius_temperature_sensor(self): """Test temperature sensor with celsius.""" device = mock_device(10, "Family Room") location = mock_location("Home", True) data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.TEMPERATURE, 21.1234)] sensor = CanarySensor(data, SensorType.TEMPERATURE, location, device) sensor.update() self.assertEqual("Home Family Room Temperature", sensor.name) self.assertEqual("sensor_canary_10_temperature", sensor.unique_id) self.assertEqual("°C", sensor.unit_of_measurement) self.assertEqual(21.1, sensor.state)
def test_humidity_sensor(self): """Test humidity sensor.""" device = mock_device(10, "Family Room") location = mock_location("Home") data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.HUMIDITY, 50.4567) ] sensor = CanarySensor(data, SensorType.HUMIDITY, location, device) sensor.update() self.assertEqual("Home Family Room Humidity", sensor.name) self.assertEqual("%", sensor.unit_of_measurement) self.assertEqual(50.5, sensor.state)
def test_fahrenheit_temperature_sensor(self): """Test temperature sensor with fahrenheit.""" device = mock_device(10, "Family Room") location = mock_location("Home", False) data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.TEMPERATURE, 21.1567) ] sensor = CanarySensor(data, SensorType.TEMPERATURE, location, device) sensor.update() self.assertEqual("Home Family Room Temperature", sensor.name) self.assertEqual("°F", sensor.unit_of_measurement) self.assertEqual(21.2, sensor.state)
def test_celsius_temperature_sensor(self): """Test temperature sensor with celsius.""" device = mock_device(10, "Family Room") location = mock_location("Home", True) data = Mock() data.get_readings.return_value = [ mock_reading(SensorType.TEMPERATURE, 21.1234) ] sensor = CanarySensor(data, SensorType.TEMPERATURE, location, device) sensor.update() self.assertEqual("Home Family Room Temperature", sensor.name) self.assertEqual("sensor_canary_10_temperature", sensor.unique_id) self.assertEqual("°C", sensor.unit_of_measurement) self.assertEqual(21.1, sensor.state)