mirror of
https://github.com/OMGeeky/flucto-heisskleber.git
synced 2026-02-23 15:38:33 +01:00
fixed ruff complaints
This commit is contained in:
@@ -3,10 +3,14 @@ import unittest.mock as mock
|
||||
|
||||
import pytest
|
||||
|
||||
from heisskleber.config import BaseConf
|
||||
from heisskleber.config.parse import (
|
||||
get_cmdline,
|
||||
get_config_dir,
|
||||
get_config_filepath,
|
||||
load_config,
|
||||
read_yaml_config_file,
|
||||
update_config,
|
||||
)
|
||||
|
||||
|
||||
@@ -16,7 +20,7 @@ def test_get_config_dir():
|
||||
|
||||
|
||||
def test_get_config_filepath():
|
||||
with mock.patch("os.path.isfile", return_value=True):
|
||||
with mock.patch("os.path.isfile", return_value=True), mock.patch("os.path.isdir", return_value=True):
|
||||
assert get_config_filepath("test_config.yaml") == os.path.join(
|
||||
os.path.join(os.environ["HOME"], ".config"),
|
||||
"heisskleber",
|
||||
@@ -37,10 +41,42 @@ def test_read_yaml_config_file():
|
||||
|
||||
|
||||
def test_update_config():
|
||||
# TODO test update_config
|
||||
pass
|
||||
conf_obj = BaseConf()
|
||||
conf_obj["verbose"] = False
|
||||
conf_obj["print_stdout"] = False
|
||||
conf_dict = {"verbose": True, "print_stdout": True}
|
||||
conf_obj = update_config(conf_obj, conf_dict)
|
||||
|
||||
assert conf_obj.verbose is True
|
||||
assert conf_obj.print_stdout is True
|
||||
|
||||
|
||||
def test_get_cmdline_patch_argv():
|
||||
with mock.patch("sys.argv", ["test.py", "--verbose"]):
|
||||
assert get_cmdline()["verbose"] is True
|
||||
|
||||
|
||||
def test_get_cmdline():
|
||||
assert (
|
||||
get_cmdline(
|
||||
[
|
||||
"--verbose",
|
||||
]
|
||||
)["verbose"]
|
||||
is True
|
||||
)
|
||||
|
||||
|
||||
def test_load_config_from_file():
|
||||
with mock.patch("heisskleber.config.parse.get_config_filepath", return_value="tests/config.yaml"):
|
||||
conf = load_config(BaseConf(), "config", read_commandline=False)
|
||||
assert conf.verbose is True
|
||||
|
||||
|
||||
def test_load_config():
|
||||
# TODO test load_config
|
||||
pass
|
||||
with mock.patch("heisskleber.config.parse.get_config_filepath", return_value="tests/config.yaml"), mock.patch(
|
||||
"sys.argv", ["test.py", "--print-stdout"]
|
||||
):
|
||||
conf = load_config(BaseConf(), "config")
|
||||
assert conf.verbose is True
|
||||
assert conf.print_stdout is True
|
||||
|
||||
Reference in New Issue
Block a user