mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
make format
This commit is contained in:
parent
7a54e6f458
commit
f1b260655d
3 changed files with 22 additions and 25 deletions
|
@ -1,11 +1,12 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from jrnl.args import parse_args
|
from jrnl.args import parse_args
|
||||||
from jrnl.jrnl import run
|
from jrnl.jrnl import run
|
||||||
from jrnl import install
|
from jrnl import install
|
||||||
|
from jrnl import jrnl
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
@ -15,15 +16,11 @@ def minimal_config():
|
||||||
"default": "/tmp/journal.jrnl",
|
"default": "/tmp/journal.jrnl",
|
||||||
"editor": "vim",
|
"editor": "vim",
|
||||||
"encrypt": False,
|
"encrypt": False,
|
||||||
"journals": {
|
"journals": {"default": "/tmp/journals/journal.jrnl"},
|
||||||
"default": "/tmp/journals/journal.jrnl"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
yield cfg
|
yield cfg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def expected_override(minimal_config):
|
def expected_override(minimal_config):
|
||||||
exp_out_cfg = minimal_config.copy()
|
exp_out_cfg = minimal_config.copy()
|
||||||
|
@ -32,9 +29,6 @@ def expected_override(minimal_config):
|
||||||
yield exp_out_cfg
|
yield exp_out_cfg
|
||||||
|
|
||||||
|
|
||||||
from jrnl import jrnl
|
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("sys.stdin.isatty")
|
@mock.patch("sys.stdin.isatty")
|
||||||
@mock.patch.object(install, "load_or_install_jrnl")
|
@mock.patch.object(install, "load_or_install_jrnl")
|
||||||
@mock.patch("subprocess.call")
|
@mock.patch("subprocess.call")
|
||||||
|
@ -76,7 +70,9 @@ def expected_color_override(minimal_config):
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("sys.stdin.isatty")
|
@mock.patch("sys.stdin.isatty")
|
||||||
@mock.patch("jrnl.install.load_or_install_jrnl", wraps=jrnl.install.load_or_install_jrnl)
|
@mock.patch(
|
||||||
|
"jrnl.install.load_or_install_jrnl", wraps=jrnl.install.load_or_install_jrnl
|
||||||
|
)
|
||||||
@mock.patch("subprocess.call")
|
@mock.patch("subprocess.call")
|
||||||
def test_override_configured_colors(
|
def test_override_configured_colors(
|
||||||
mock_isatty,
|
mock_isatty,
|
||||||
|
@ -94,7 +90,7 @@ def test_override_configured_colors(
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
jrnl,
|
jrnl,
|
||||||
"_write_in_editor",
|
"_write_in_editor",
|
||||||
side_effect= print("side effect!"),
|
side_effect=print("side effect!"),
|
||||||
return_value="note_contents",
|
return_value="note_contents",
|
||||||
) as mock_write_in_editor:
|
) as mock_write_in_editor:
|
||||||
run(parser)
|
run(parser)
|
||||||
|
|
|
@ -9,10 +9,7 @@ def minimal_config():
|
||||||
"colors": {"body": "red", "date": "green"},
|
"colors": {"body": "red", "date": "green"},
|
||||||
"default": "/tmp/journal.jrnl",
|
"default": "/tmp/journal.jrnl",
|
||||||
"editor": "vim",
|
"editor": "vim",
|
||||||
"journals": {
|
"journals": {"default": "/tmp/journals/journal.jrnl"},
|
||||||
"default": "/tmp/journals/journal.jrnl"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
yield cfg
|
yield cfg
|
||||||
|
|
||||||
|
@ -30,11 +27,12 @@ def test_override_dot_notation(minimal_config):
|
||||||
cfg = apply_overrides(overrides=overrides, base_config=cfg)
|
cfg = apply_overrides(overrides=overrides, base_config=cfg)
|
||||||
assert cfg["colors"] == {"body": "blue", "date": "green"}
|
assert cfg["colors"] == {"body": "blue", "date": "green"}
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_overrides(minimal_config):
|
def test_multiple_overrides(minimal_config):
|
||||||
overrides = {
|
overrides = {
|
||||||
"colors.title": "magenta",
|
"colors.title": "magenta",
|
||||||
"editor": "nano",
|
"editor": "nano",
|
||||||
"journals.burner": "/tmp/journals/burner.jrnl"
|
"journals.burner": "/tmp/journals/burner.jrnl",
|
||||||
} # as returned by parse_args, saved in parser.config_override
|
} # as returned by parse_args, saved in parser.config_override
|
||||||
cfg = apply_overrides(overrides, minimal_config.copy())
|
cfg = apply_overrides(overrides, minimal_config.copy())
|
||||||
assert cfg["editor"] == "nano"
|
assert cfg["editor"] == "nano"
|
||||||
|
@ -42,6 +40,7 @@ def test_multiple_overrides(minimal_config):
|
||||||
assert "burner" in cfg["journals"]
|
assert "burner" in cfg["journals"]
|
||||||
assert cfg["journals"]["burner"] == "/tmp/journals/burner.jrnl"
|
assert cfg["journals"]["burner"] == "/tmp/journals/burner.jrnl"
|
||||||
|
|
||||||
|
|
||||||
def test_recursively_apply():
|
def test_recursively_apply():
|
||||||
cfg = {"colors": {"body": "red", "title": "green"}}
|
cfg = {"colors": {"body": "red", "title": "green"}}
|
||||||
cfg = _recursively_apply(cfg, ["colors", "body"], "blue")
|
cfg = _recursively_apply(cfg, ["colors", "body"], "blue")
|
||||||
|
|
|
@ -219,6 +219,7 @@ def test_color_override():
|
||||||
'--config-override \'{"colors.body": "blue"}\''
|
'--config-override \'{"colors.body": "blue"}\''
|
||||||
) == expected_args(config_override={"colors.body": "blue"})
|
) == expected_args(config_override={"colors.body": "blue"})
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_overrides():
|
def test_multiple_overrides():
|
||||||
assert cli_as_dict(
|
assert cli_as_dict(
|
||||||
'--config-override \'{"colors.title": "green", "editor":"", "journal.scratchpad": "/tmp/scratchpad"}\''
|
'--config-override \'{"colors.title": "green", "editor":"", "journal.scratchpad": "/tmp/scratchpad"}\''
|
||||||
|
@ -226,10 +227,11 @@ def test_multiple_overrides():
|
||||||
config_override={
|
config_override={
|
||||||
"colors.title": "green",
|
"colors.title": "green",
|
||||||
"journal.scratchpad": "/tmp/scratchpad",
|
"journal.scratchpad": "/tmp/scratchpad",
|
||||||
"editor": ""
|
"editor": "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# @see https://github.com/jrnl-org/jrnl/issues/520
|
# @see https://github.com/jrnl-org/jrnl/issues/520
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"cli",
|
"cli",
|
||||||
|
|
Loading…
Add table
Reference in a new issue