mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-04 23:46:14 +02:00
make format
This commit is contained in:
parent
99030c4623
commit
b92dd7edc7
6 changed files with 69 additions and 63 deletions
|
@ -43,7 +43,8 @@ def test_override_configured_editor(
|
|||
cli_args = ["--config-override", '{"editor": "nano"}']
|
||||
parser = parse_args(cli_args)
|
||||
assert parser.config_override.__len__() == 1
|
||||
assert "editor" in parser.config_override.keys()
|
||||
assert "editor" in parser.config_override.keys()
|
||||
|
||||
def mock_editor_launch(editor):
|
||||
print("%s launched! Success!" % editor)
|
||||
|
||||
|
@ -56,21 +57,21 @@ def test_override_configured_editor(
|
|||
run(parser)
|
||||
mock_write_in_editor.assert_called_once_with(expected_override)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def expected_color_override(minimal_config):
|
||||
exp_out_cfg = minimal_config.copy()
|
||||
def expected_color_override(minimal_config):
|
||||
exp_out_cfg = minimal_config.copy()
|
||||
exp_out_cfg["colors"] = {"body": "blue"}
|
||||
exp_out_cfg["journal"] = "features/journals/simple.journal"
|
||||
yield exp_out_cfg
|
||||
|
||||
|
||||
# @mock.patch.object(install,'load_or_install_jrnl')
|
||||
# @mock.patch('subprocess.call')
|
||||
# def test_override_configured_colors(mock_load_or_install, mock_subprocess_call, minimal_config, expected_color_override, capsys):
|
||||
# def test_override_configured_colors(mock_load_or_install, mock_subprocess_call, minimal_config, expected_color_override, capsys):
|
||||
# mock_load_or_install.return_value = minimal_config
|
||||
|
||||
|
||||
# cli_args=["--config-override",'{"colors.body": "blue"}']
|
||||
# parser = parse_args(cli_args)
|
||||
# assert "colors.body" in parser.config_override.keys()
|
||||
# assert "colors.body" in parser.config_override.keys()
|
||||
# run(parser)
|
||||
|
||||
|
||||
|
|
|
@ -1,41 +1,34 @@
|
|||
import pytest
|
||||
|
||||
from jrnl.override import apply_overrides, recursively_apply
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def minimal_config():
|
||||
cfg = {
|
||||
"colors":{
|
||||
"body":"red",
|
||||
"date":"green"
|
||||
},
|
||||
"default":"/tmp/journal.jrnl",
|
||||
"editor":"vim"
|
||||
def minimal_config():
|
||||
cfg = {
|
||||
"colors": {"body": "red", "date": "green"},
|
||||
"default": "/tmp/journal.jrnl",
|
||||
"editor": "vim",
|
||||
}
|
||||
yield cfg
|
||||
yield cfg
|
||||
|
||||
def test_apply_override(minimal_config):
|
||||
|
||||
def test_apply_override(minimal_config):
|
||||
config = minimal_config.copy()
|
||||
overrides = {
|
||||
'editor':'nano'
|
||||
}
|
||||
overrides = {"editor": "nano"}
|
||||
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"
|
||||
}
|
||||
|
||||
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"}
|
||||
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"
|
||||
|
||||
def test_recursive_override(minimal_config):
|
||||
|
||||
cfg = {"colors": {"body": "red", "title": "green"}}
|
||||
cfg = recursively_apply(cfg, ["colors", "body"], "blue")
|
||||
assert cfg["colors"]["body"] == "blue"
|
||||
|
|
|
@ -211,10 +211,13 @@ def test_editor_override():
|
|||
assert cli_as_dict('--config-override \'{"editor": "nano"}\'') == expected_args(
|
||||
config_override={"editor": "nano"}
|
||||
)
|
||||
def test_color_override():
|
||||
assert cli_as_dict('--config-override \'{"colors.body": "blue"}\'') == expected_args(
|
||||
config_override={"colors.body":"blue"}
|
||||
)
|
||||
|
||||
|
||||
def test_color_override():
|
||||
assert cli_as_dict(
|
||||
'--config-override \'{"colors.body": "blue"}\''
|
||||
) == expected_args(config_override={"colors.body": "blue"})
|
||||
|
||||
|
||||
# @see https://github.com/jrnl-org/jrnl/issues/520
|
||||
@pytest.mark.parametrize(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue