mirror of
https://github.com/ManiMatter/decluttarr.git
synced 2026-04-18 06:54:01 +02:00
Formatting issues
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Test loading the user configuration from environment variables."""
|
||||
|
||||
import os
|
||||
import textwrap
|
||||
from unittest.mock import patch
|
||||
@@ -16,47 +17,61 @@ TIMER_VALUE = "10"
|
||||
SSL_VERIFICATION_VALUE = "true"
|
||||
|
||||
# List
|
||||
ignored_download_clients_yaml = textwrap.dedent("""
|
||||
ignored_download_clients_yaml = textwrap.dedent(
|
||||
"""
|
||||
- emulerr
|
||||
- napster
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
# Job: No settings
|
||||
remove_bad_files_yaml = "" # pylint: disable=C0103; empty string represents flag enabled with no config
|
||||
remove_bad_files_yaml = ( # pylint: disable=C0103; empty string represents flag enabled with no config
|
||||
""
|
||||
)
|
||||
|
||||
# Job: One Setting
|
||||
remove_slow_yaml = textwrap.dedent("""
|
||||
remove_slow_yaml = textwrap.dedent(
|
||||
"""
|
||||
- max_strikes: 3
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
# Job: Multiple Setting
|
||||
remove_stalled_yaml = textwrap.dedent("""
|
||||
remove_stalled_yaml = textwrap.dedent(
|
||||
"""
|
||||
- min_speed: 100
|
||||
- max_strikes: 3
|
||||
- some_bool_upper: TRUE
|
||||
- some_bool_lower: false
|
||||
- some_bool_sentence: False
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
# Arr Instances
|
||||
radarr_yaml = textwrap.dedent("""
|
||||
radarr_yaml = textwrap.dedent(
|
||||
"""
|
||||
- base_url: "http://radarr:7878"
|
||||
api_key: "radarr1_key"
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
sonarr_yaml = textwrap.dedent("""
|
||||
sonarr_yaml = textwrap.dedent(
|
||||
"""
|
||||
- base_url: "sonarr_1_api_key"
|
||||
api_key: "sonarr1_api_url"
|
||||
- base_url: "sonarr_2_api_key"
|
||||
api_key: "sonarr2_api_url"
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
# Qbit Instances
|
||||
qbit_yaml = textwrap.dedent("""
|
||||
qbit_yaml = textwrap.dedent(
|
||||
"""
|
||||
- base_url: "http://qbittorrent:8080"
|
||||
username: "qbit_username1"
|
||||
password: "qbit_password1"
|
||||
""").strip()
|
||||
"""
|
||||
).strip()
|
||||
|
||||
|
||||
@pytest.fixture(name="env_vars")
|
||||
@@ -87,19 +102,28 @@ sonarr_expected = yaml.safe_load(sonarr_yaml)
|
||||
qbit_expected = yaml.safe_load(qbit_yaml)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("section", "key", "expected"), [
|
||||
("general", "log_level", LOG_LEVEL_VALUE),
|
||||
("general", "timer", int(TIMER_VALUE)),
|
||||
("general", "ssl_verification", True),
|
||||
("general", "ignored_download_clients", remove_ignored_download_clients_expected),
|
||||
("jobs", "remove_bad_files", remove_bad_files_expected),
|
||||
("jobs", "remove_slow", remove_slow_expected),
|
||||
("jobs", "remove_stalled", remove_stalled_expected),
|
||||
("instances", "radarr", radarr_expected),
|
||||
("instances", "sonarr", sonarr_expected),
|
||||
("download_clients", "qbittorrent", qbit_expected),
|
||||
])
|
||||
def test_env_loading_parametrized(env_vars, section, key, expected): # pylint: disable=unused-argument # noqa: ARG001
|
||||
@pytest.mark.parametrize(
|
||||
("section", "key", "expected"),
|
||||
[
|
||||
("general", "log_level", LOG_LEVEL_VALUE),
|
||||
("general", "timer", int(TIMER_VALUE)),
|
||||
("general", "ssl_verification", True),
|
||||
(
|
||||
"general",
|
||||
"ignored_download_clients",
|
||||
remove_ignored_download_clients_expected,
|
||||
),
|
||||
("jobs", "remove_bad_files", remove_bad_files_expected),
|
||||
("jobs", "remove_slow", remove_slow_expected),
|
||||
("jobs", "remove_stalled", remove_stalled_expected),
|
||||
("instances", "radarr", radarr_expected),
|
||||
("instances", "sonarr", sonarr_expected),
|
||||
("download_clients", "qbittorrent", qbit_expected),
|
||||
],
|
||||
)
|
||||
def test_env_loading_parametrized(
|
||||
env_vars, section, key, expected
|
||||
): # pylint: disable=unused-argument # noqa: ARG001
|
||||
config = _load_from_env()
|
||||
assert section in config
|
||||
assert key in config[section]
|
||||
|
||||
Reference in New Issue
Block a user