コード例 #1
0
def test_atlas_ph_special_method_repr():
    """ expect a __repr__ format """
    with mock.patch('mycodo.inputs.atlas_ph.AtlaspHSensor.get_measurement'
                    ) as mock_measure:
        mock_measure.side_effect = [0.0]
        atlas_ph = AtlaspHSensor(None, testing=True)
        atlas_ph.read()
        assert "<AtlaspHSensor(ph=0.00)>" in repr(atlas_ph)
コード例 #2
0
def test_atlas_ph_read_updates_temp():
    """  Verify that AtlaspHSensor(0x99, 1).read() gets the average temp """
    with mock.patch('mycodo.inputs.atlas_ph.AtlaspHSensor.get_measurement'
                    ) as mock_measure:
        mock_measure.side_effect = [67, 52]
        atlas_ph = AtlaspHSensor(None, testing=True)
        assert atlas_ph._ph is None
        assert not atlas_ph.read()
        assert atlas_ph._ph == 67.0
        assert not atlas_ph.read()
        assert atlas_ph._ph == 52.0
コード例 #3
0
def test_atlas_ph_condition_properties():
    """ verify ph property """
    with mock.patch('mycodo.inputs.atlas_ph.AtlaspHSensor.get_measurement'
                    ) as mock_measure:
        mock_measure.side_effect = [67, 52]
        atlas_ph = AtlaspHSensor(None, testing=True)
        assert atlas_ph._ph is None
        assert atlas_ph.ph == 67.00
        assert atlas_ph.ph == 67.00
        assert not atlas_ph.read()
        assert atlas_ph.ph == 52.00