From 2d7ff736961fef076490a449f735a596ec0dec43 Mon Sep 17 00:00:00 2001 From: Suhas Date: Sun, 24 Jan 2021 11:09:23 -0500 Subject: [PATCH] clean up unittests --- tests/test_config.py | 4 ++-- tests/test_override.py | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index d41b2de2..17fc409d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,14 +4,14 @@ import mock import yaml from jrnl.args import parse_args -from jrnl.jrnl import run, search_mode +from jrnl.jrnl import run from jrnl import install @pytest.fixture() def minimal_config(): 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 diff --git a/tests/test_override.py b/tests/test_override.py index 25f38243..680cb872 100644 --- a/tests/test_override.py +++ b/tests/test_override.py @@ -1,11 +1,6 @@ import pytest -import mock - -from jrnl.args import parse_args -from jrnl.jrnl import run, search_mode -from jrnl import install -from jrnl.override import apply_overrides +from jrnl.override import apply_overrides, recursively_apply @pytest.fixture() def minimal_config(): cfg = { @@ -24,4 +19,23 @@ def test_apply_override(minimal_config): 'editor':'nano' } config = apply_overrides(overrides, config) - assert config['editor']=='nano' \ No newline at end of file + 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" \ No newline at end of file