-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Bring code coverage back to 100%
- Loading branch information
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from ds18b20_datalogger.model import Device, Settings | ||
|
||
|
||
@pytest.fixture | ||
def settings() -> Settings: | ||
configfile = Path("etc") / "mois.yaml" | ||
return Settings.from_file(configfile) | ||
|
||
|
||
def test_model_devicemap_by_name_success(settings): | ||
assert settings.devicemap.by_name("temp-ir-1-1") == Device( | ||
name="temp-ir-1-1", path="/sys/bus/w1/devices/28-0346d4430b06" | ||
) | ||
|
||
|
||
def test_model_devicemap_by_name_failure(settings): | ||
with pytest.raises(KeyError) as ex: | ||
settings.devicemap.by_name("foo") | ||
assert ex.match("'Device not found: name=foo'") | ||
|
||
|
||
def test_model_devicemap_by_fullpath_success(settings): | ||
assert settings.devicemap.by_fullpath("/sys/bus/w1/devices/28-0346d4430b06") == Device( | ||
name="temp-ir-1-1", path="/sys/bus/w1/devices/28-0346d4430b06" | ||
) | ||
|
||
|
||
def test_model_devicemap_by_fullpath_failure(settings): | ||
with pytest.raises(KeyError) as ex: | ||
settings.devicemap.by_fullpath("foo") | ||
assert ex.match("'Device not found: path=foo'") | ||
|
||
|
||
def test_model_devicemap_by_pathname_success(settings): | ||
assert settings.devicemap.by_pathname("28-0346d4430b06") == Device( | ||
name="temp-ir-1-1", path="/sys/bus/w1/devices/28-0346d4430b06" | ||
) | ||
|
||
|
||
def test_model_devicemap_by_pathname_failure(settings): | ||
with pytest.raises(KeyError) as ex: | ||
settings.devicemap.by_pathname("foo") | ||
assert ex.match("'Device not found: pathname=foo'") |