Example #1
0
def test_raspi_freespace_special_method_str():
    """ expect a __str__ format """
    with mock.patch(
            'mycodo.inputs.raspi_freespace.RaspberryPiFreeSpace.get_measurement'
    ) as mock_measure:
        mock_measure.side_effect = [0.0]
        raspi_freespace = RaspberryPiFreeSpace(None, testing=True)
        raspi_freespace.read()
        assert "Free Space: 0.00" in str(raspi_freespace)
Example #2
0
def test_raspi_freespace_read_updates_temp():
    """  Verify that RaspberryPiFreeSpace(0x99, 1).read() gets the average temp """
    with mock.patch(
            'mycodo.inputs.raspi_freespace.RaspberryPiFreeSpace.get_measurement'
    ) as mock_measure:
        mock_measure.side_effect = [67, 52]
        raspi_freespace = RaspberryPiFreeSpace(None, testing=True)
        assert raspi_freespace._disk_space is None
        assert not raspi_freespace.read()
        assert raspi_freespace._disk_space == 67.0
        assert not raspi_freespace.read()
        assert raspi_freespace._disk_space == 52.0
Example #3
0
def test_raspi_freespace_condition_properties():
    """ verify disk_space property """
    with mock.patch(
            'mycodo.inputs.raspi_freespace.RaspberryPiFreeSpace.get_measurement'
    ) as mock_measure:
        mock_measure.side_effect = [67, 52]
        raspi_freespace = RaspberryPiFreeSpace(None, testing=True)
        assert raspi_freespace._disk_space is None
        assert raspi_freespace.disk_space == 67.00
        assert raspi_freespace.disk_space == 67.00
        assert not raspi_freespace.read()
        assert raspi_freespace.disk_space == 52.00