def test_read_broken_temperatures0001(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # Unit is missing (expect degC suffix)
            return "hw.sensors.some_temp0=10"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Odd non-degC value" in caplog.text()
    def test_read_broken_temperatures0002(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # value (prior to degC) should be float()able
            return "hw.sensors.some_temp0=inferno degC"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Non-numeric value" in caplog.text()
    def test_read_broken_temperatures0003(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # Weird unit (not degC)
            return "hw.sensors.some_temp0=66 kravits"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Odd non-degC value" in caplog.text()
Exemple #4
0
    def test_read_broken_temperatures0001(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # Unit is missing (expect degC suffix)
            return "hw.sensors.some_temp0=10"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Odd non-degC value" in caplog.text()
Exemple #5
0
    def test_read_broken_temperatures0003(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # Weird unit (not degC)
            return "hw.sensors.some_temp0=66 kravits"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Odd non-degC value" in caplog.text()
Exemple #6
0
    def test_read_broken_temperatures0002(self, monkeypatch, platform, caplog):
        platform.temp_sensors = ["hw.sensors.some_temp0"]

        def dummy(self, sensor):
            # value (prior to degC) should be float()able
            return "hw.sensors.some_temp0=inferno degC"

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor", dummy)

        with pytest.raises(FatalKrunError):
            platform.take_temperature_readings()

        assert "Non-numeric value" in caplog.text()
    def test_take_temperature_readings0002(self, platform, monkeypatch):
        """Test with fake readings"""

        platform.temp_sensors = [
            "hw.sensors.cpu0.temp0",
            "hw.sensors.acpitz0.temp0",
        ]

        def fake__raw_read_temperature_sensor(self, sensor):
            if sensor == "hw.sensors.cpu0.temp0":
                return "hw.sensors.cpu0.temp0=64.00 degC"
            elif sensor == "hw.sensors.acpitz0.temp0":
                return "hw.sensors.acpitz0.temp0=65.58 degC (zone temperature)"
            else:
                assert False

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor",
                            fake__raw_read_temperature_sensor)

        # Results were already in degrees C
        expect = {
            "hw.sensors.cpu0.temp0": 64.00,
            "hw.sensors.acpitz0.temp0": 65.58,
        }
        got = platform.take_temperature_readings()

        assert expect == got
Exemple #8
0
    def test_take_temperature_readings0002(self, platform, monkeypatch):
        platform.temp_sensors = [
            "x:temp1_input",
            "y:temp1_input",
            "y:temp2_input",
        ]

        def fake_read_zone(self, zone):
            if zone == "x:temp1_input":
                return 66123
            elif zone == "y:temp1_input":
                return 0
            else:
                return 100000

        monkeypatch.setattr(krun.platform.LinuxPlatform,
                            "_read_temperature_sensor", fake_read_zone)

        expect = {
            "x:temp1_input": 66.123,
            "y:temp1_input": 0.0,
            "y:temp2_input": 100.0
        }
        got = platform.take_temperature_readings()

        assert expect == got
Exemple #9
0
    def test_take_temperature_readings0002(self, platform, monkeypatch):
        """Test with fake readings"""

        platform.temp_sensors = [
            "hw.sensors.cpu0.temp0",
            "hw.sensors.acpitz0.temp0",
        ]

        def fake__raw_read_temperature_sensor(self, sensor):
            if sensor == "hw.sensors.cpu0.temp0":
                return "hw.sensors.cpu0.temp0=64.00 degC"
            elif sensor == "hw.sensors.acpitz0.temp0":
                return "hw.sensors.acpitz0.temp0=65.58 degC (zone temperature)"
            else:
                assert False

        monkeypatch.setattr(krun.platform.OpenBSDPlatform,
                            "_raw_read_temperature_sensor",
                            fake__raw_read_temperature_sensor)

        # Results were already in degrees C
        expect = {
            "hw.sensors.cpu0.temp0": 64.00,
            "hw.sensors.acpitz0.temp0": 65.58,
        }
        got = platform.take_temperature_readings()

        assert expect == got
    def test_take_temperature_readings0001(self, platform):
        """Test live readings off test machine"""

        temps = platform.take_temperature_readings()
        assert type(temps) is dict
        assert all([x.startswith("hw.sensors.") for x in temps.iterkeys()])
        # check temperature readings are within reasonable parameters
        assert all([type(v) == float for v in temps.itervalues()])
        assert all([10 <= v <= 120 for v in temps.itervalues()])
Exemple #11
0
    def test_take_temperature_readings0001(self, platform):
        """Test live readings off test machine"""

        temps = platform.take_temperature_readings()
        assert type(temps) is dict
        assert all([x.startswith("hw.sensors.") for x in temps.iterkeys()])
        # check temperature readings are within reasonable parameters
        assert all([type(v) == float for v in temps.itervalues()])
        assert all([10 <= v <= 120 for v in temps.itervalues()])
Exemple #12
0
    def test_take_temperature_readings0001(self, platform):
        """Test live readings off test machine"""

        temps = platform.take_temperature_readings()
        assert type(temps) is dict

        for sid in temps.iterkeys():
            elems = sid.split(":")
            assert len(elems) == 2
            assert elems[1].endswith("_input")

        # check temperature readings are within reasonable parameters
        assert all([type(v) == float for v in temps.itervalues()])
        assert all([10 <= v <= 100 for v in temps.itervalues()])