Got tests for settings.

Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
2021-09-30 11:59:32 -04:00
parent 9fce1a6028
commit effb5a6fce
2 changed files with 37 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
"""Tests for validating the Settings object."""
import pathlib
import pytest # type: ignore [import]
from playlist.data import settings # type: ignore [import]
@pytest.fixture # type: ignore [misc]
def example_settings() -> settings.Settings:
"""Make testable Settings object."""
return settings.Settings(
creds=settings.CredentialSettings(baseurl="http://nowhere.huh", token="12345"),
)
@pytest.fixture # type: ignore [misc]
def settings_filepath(tmp_path: pathlib.Path) -> pathlib.Path:
"""Get the path to use for the settings file."""
return tmp_path / "fake_settings.yaml"
def test_yaml(
example_settings: settings.Settings,
settings_filepath: pathlib.Path,
) -> None:
"""Test the YAML read/write operations."""
example_settings.yaml_write(settings_filepath)
result = example_settings.yaml_read(settings_filepath)
assert result == example_settings