Skip to content

Commit d0d86e1

Browse files
committed
more tests for installer-config
1 parent 120e12b commit d0d86e1

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ lint:
1212
poetry run ruff openandroidinstaller/ --ignore E501
1313

1414
test:
15+
poetry run black .
16+
poetry run ruff openandroidinstaller/ --ignore E501
1517
poetry run pytest --cov=openandroidinstaller tests/
1618

1719
app:

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
from pathlib import Path
3+
4+
5+
@pytest.fixture
6+
def config_path():
7+
return Path("openandroidinstaller/assets/configs")

tests/test_configs.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
import yaml
77

8-
from openandroidinstaller.installer_config import validate_config
8+
from openandroidinstaller.installer_config import validate_config, _load_config
99

1010

1111
@pytest.mark.parametrize(
@@ -17,3 +17,20 @@ def test_config(config_path: Path, valid: bool):
1717
with open(config_path, "r") as stream:
1818
raw_config = yaml.safe_load(stream)
1919
assert valid == validate_config(raw_config)
20+
21+
22+
def test_load_config_valid(config_path):
23+
"""Test if a valid config can be loaded."""
24+
config = _load_config(device_code="sargo", config_path=config_path)
25+
26+
# assert some properties of the config
27+
assert config
28+
assert config.metadata.get("devicecode") == "sargo"
29+
30+
31+
def test_load_config_notfound(config_path):
32+
"""Test if the function properly escalates when a config is not found."""
33+
config = _load_config(device_code="nothing", config_path=config_path)
34+
35+
# assert some properties of the config
36+
assert config == None

0 commit comments

Comments
 (0)