mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
clean up unittests
This commit is contained in:
parent
f3d8ed2e45
commit
2d7ff73696
2 changed files with 23 additions and 9 deletions
|
@ -4,14 +4,14 @@ import mock
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from jrnl.args import parse_args
|
from jrnl.args import parse_args
|
||||||
from jrnl.jrnl import run, search_mode
|
from jrnl.jrnl import run
|
||||||
from jrnl import install
|
from jrnl import install
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def minimal_config():
|
def minimal_config():
|
||||||
with open("features/data/configs/editor.yaml", "r") as cfg_file:
|
with open("features/data/configs/editor.yaml", "r") as cfg_file:
|
||||||
cfg = yaml.load(cfg_file.read())
|
cfg = yaml.load(cfg_file.read(), Loader=yaml.FullLoader)
|
||||||
yield cfg
|
yield cfg
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import mock
|
from jrnl.override import apply_overrides, recursively_apply
|
||||||
|
|
||||||
from jrnl.args import parse_args
|
|
||||||
from jrnl.jrnl import run, search_mode
|
|
||||||
from jrnl import install
|
|
||||||
from jrnl.override import apply_overrides
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def minimal_config():
|
def minimal_config():
|
||||||
cfg = {
|
cfg = {
|
||||||
|
@ -24,4 +19,23 @@ def test_apply_override(minimal_config):
|
||||||
'editor':'nano'
|
'editor':'nano'
|
||||||
}
|
}
|
||||||
config = apply_overrides(overrides, config)
|
config = apply_overrides(overrides, config)
|
||||||
assert config['editor']=='nano'
|
assert config['editor']=='nano'
|
||||||
|
|
||||||
|
def test_override_dot_notation(minimal_config):
|
||||||
|
cfg = minimal_config.copy()
|
||||||
|
overrides = {
|
||||||
|
"colors.body": "blue"
|
||||||
|
}
|
||||||
|
cfg = apply_overrides(overrides=overrides, base_config=cfg)
|
||||||
|
assert cfg["colors"] == {"body": "blue", "date":"green"}
|
||||||
|
|
||||||
|
def test_recursive_override(minimal_config):
|
||||||
|
|
||||||
|
cfg = {
|
||||||
|
"colors": {
|
||||||
|
"body": "red",
|
||||||
|
"title": "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg = recursively_apply(cfg,["colors",'body'],"blue")
|
||||||
|
assert cfg["colors"]["body"] == "blue"
|
Loading…
Add table
Reference in a new issue