File: test_hwmon.py

package info (click to toggle)
liquidctl 1.16.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,452 kB
  • sloc: python: 15,304; sh: 712; xml: 84; makefile: 4
file content (44 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# uses the psf/black style

import pytest

from liquidctl.driver.hwmon import HwmonDevice


@pytest.fixture
def mock_hwmon(tmp_path):
    hwmon = tmp_path / "hwmon7"
    hwmon.mkdir()

    (hwmon / "fan1_input").write_text("1499\n")
    (hwmon / "fan1_label").write_text("Pump Speed\n")

    return HwmonDevice("mock_module", hwmon)


def test_has_module(mock_hwmon):
    assert mock_hwmon.driver == "mock_module"


def test_has_path(mock_hwmon):
    assert mock_hwmon.path.is_dir()


def test_has_name(mock_hwmon):
    assert mock_hwmon.name == "hwmon7"


def test_checks_existing_attribute(mock_hwmon):
    assert mock_hwmon.has_attribute("fan1_input")


def test_checks_non_existing_attribute(mock_hwmon):
    assert not mock_hwmon.has_attribute("bubble1_input")


def test_gets_string(mock_hwmon):
    assert mock_hwmon.get_string("fan1_label") == "Pump Speed"


def test_gets_int(mock_hwmon):
    assert mock_hwmon.read_int("fan1_input") == 1499