def test_bmp_special_method_repr(): """ expect a __repr__ format """ with mock.patch( 'mycodo.inputs.chirp.ChirpSensor.get_measurement') as mock_measure: mock_measure.side_effect = [(0, 0, 0)] chirp = ChirpSensor(None, testing=True) chirp.read() assert "<ChirpSensor(lux=0)(moisture=0)(temperature=0.00)>" in repr( chirp)
def test_bmp_special_method_str(): """ expect a __str__ format """ with mock.patch( 'mycodo.inputs.chirp.ChirpSensor.get_measurement') as mock_measure: mock_measure.side_effect = [(0, 0, 0)] chirp = ChirpSensor(None, testing=True) chirp.read() assert "Temperature: 0.00" in str(chirp) assert "Moisture: 0" in str(chirp) assert "Light: 0" in str(chirp)
def test_bmp_read_updates_temp(): """ Verify that ChirpSensor(None, testing=True).read() gets the average temp """ with mock.patch( 'mycodo.inputs.chirp.ChirpSensor.get_measurement') as mock_measure: mock_measure.side_effect = [(67, 33, 2000), (52, 59, 2500)] bmp = ChirpSensor(None, testing=True) assert bmp._temperature is None assert bmp._moisture is None assert bmp._lux is None assert not bmp.read() assert bmp._temperature == 2000.0 assert bmp._moisture == 33.0 assert bmp._lux == 67.0 assert not bmp.read() assert bmp._temperature == 2500.0 assert bmp._moisture == 59.0 assert bmp._lux == 52.0
def test_bmp_condition_properties(): """ verify lux property """ with mock.patch( 'mycodo.inputs.chirp.ChirpSensor.get_measurement') as mock_measure: mock_measure.side_effect = [(67, 50, 3000), (52, 55, 3500)] bmp = ChirpSensor(None, testing=True) assert bmp._temperature is None assert bmp._moisture is None assert bmp._lux is None assert bmp.temperature == 3000.00 assert bmp.temperature == 3000.00 assert bmp.moisture == 50.00 assert bmp.moisture == 50.00 assert bmp.lux == 67.00 assert bmp.lux == 67.00 assert not bmp.read() assert bmp.temperature == 3500.00 assert bmp.moisture == 55.00 assert bmp.lux == 52.00