diff --git a/features/data/configs/work-config.yaml b/features/data/configs/work-config.yaml new file mode 100644 index 00000000..c60cae5a --- /dev/null +++ b/features/data/configs/work-config.yaml @@ -0,0 +1,13 @@ +default_hour: 9 +default_hour: 9 +default_minute: 0 +editor: noop +template: false +encrypt: false +highlight: true +journals: + default: features/journals/work +linewrap: 80 +tagsymbols: '@' +timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/jrnl/install.py b/jrnl/install.py index d805f69a..6e2dac16 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -36,7 +36,7 @@ def upgrade_config(config): ) -def get_default_config(): +def find_default_config(): config_path = ( get_config_path() if os.path.exists(get_config_path()) @@ -45,7 +45,7 @@ def get_default_config(): return config_path -def get_alt_config(alt_config): +def find_alt_config(alt_config): if os.path.exists(alt_config): return alt_config else: @@ -62,7 +62,7 @@ def load_or_install_jrnl(alt_config): If alternate config is specified via --config-file flag, it will be used. Else, perform various prompts to install jrnl. """ - config_path = get_alt_config(alt_config) if alt_config else get_default_config() + config_path = find_alt_config(alt_config) if alt_config else find_default_config() if os.path.exists(config_path): logging.debug("Reading configuration from file %s", config_path) diff --git a/tests/test_config_file.py b/tests/test_config_file.py new file mode 100644 index 00000000..ec012144 --- /dev/null +++ b/tests/test_config_file.py @@ -0,0 +1,17 @@ +import pytest + +from jrnl.install import find_alt_config + + +def test_find_alt_config(): + work_config_path = "features/data/configs/work-config.yaml" + found_alt_config = find_alt_config(work_config_path) + assert found_alt_config == work_config_path + + +def test_find_alt_config_not_exist(): + bad_config_path = "features/data/configs/not-existing-config.yaml" + with pytest.raises(SystemExit) as ex: + found_alt_config = find_alt_config(bad_config_path) + assert found_alt_config is not None + assert isinstance(ex.value, SystemExit) diff --git a/tests/test_parse_args.py b/tests/test_parse_args.py index 4b140fc1..f20c8dad 100644 --- a/tests/test_parse_args.py +++ b/tests/test_parse_args.py @@ -37,6 +37,7 @@ def expected_args(**kwargs): "tags": False, "text": [], "config_override": [], + "config_file_path": "", } return {**default_args, **kwargs}