mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
rework core run() so config_upgrade can be tested
This commit is contained in:
parent
ce930a27a1
commit
c9404d013d
1 changed files with 9 additions and 5 deletions
|
@ -388,14 +388,18 @@ def all_input_was_used(context):
|
|||
for temp in context.iter_text:
|
||||
assert "" == temp, "Not all inputs were consumed"
|
||||
|
||||
|
||||
@when('we run "{command}"')
|
||||
@when('we run "{command}" and pipe')
|
||||
@when('we run "{command}" and pipe "{text}"')
|
||||
def run(context, command, text=""):
|
||||
text = text or context.text or ""
|
||||
|
||||
if "config_path" in context and context.config_path is not None:
|
||||
with open(context.config_path) as f:
|
||||
context.jrnl_config = yaml.load(f,Loader=yaml.FullLoader)
|
||||
context.jrnl_config = yaml.load(f, Loader=yaml.FullLoader)
|
||||
else:
|
||||
context.jrnl_config = None
|
||||
|
||||
if "cache_dir" in context and context.cache_dir is not None:
|
||||
cache_dir = os.path.join("features", "cache", context.cache_dir)
|
||||
command = command.format(cache_dir=cache_dir)
|
||||
|
@ -425,7 +429,7 @@ def run(context, command, text=""):
|
|||
patch("sys.stdin.read", side_effect=lambda: text), \
|
||||
patch("jrnl.time.parse", side_effect=_mock_time_parse(context)), \
|
||||
patch("jrnl.config.get_config_path", side_effect=lambda: context.config_path), \
|
||||
patch("jrnl.install.load_or_install_jrnl",return_value = context.jrnl_config), \
|
||||
patch("jrnl.install.load_or_install_jrnl",wraps=jrnl.install.load_or_install_jrnl), \
|
||||
patch("jrnl.install.get_config_path", side_effect=lambda: context.config_path) \
|
||||
:
|
||||
context.editor = mock_editor
|
||||
|
|
Loading…
Add table
Reference in a new issue