mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Fix tests
This commit is contained in:
parent
dbc98749cc
commit
5908ae6667
3 changed files with 29 additions and 21 deletions
|
@ -51,8 +51,7 @@ Feature: Using templates
|
||||||
Given we use the config "<config_file>"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
When we run "jrnl --template features/templates/basic.template"
|
When we run "jrnl --template features/templates/basic.template"
|
||||||
And we run "jrnl -1"
|
Then the output should contain "No entry to save, because the template was not changed"
|
||||||
Then the output should contain "This text is in the basic template"
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config_file |
|
| config_file |
|
||||||
|
@ -61,29 +60,13 @@ Feature: Using templates
|
||||||
| basic_folder.yaml |
|
| basic_folder.yaml |
|
||||||
| basic_dayone.yaml |
|
| basic_dayone.yaml |
|
||||||
|
|
||||||
@todo
|
|
||||||
Scenario Outline: --template absolute_filepath should be used in new entry
|
|
||||||
Given we use the config "<config_file>"
|
|
||||||
And we use the password "test" if prompted
|
|
||||||
When we run "jrnl --template /tmp/basic.template"
|
|
||||||
And we run "jrnl -1"
|
|
||||||
Then the output should contain "This text is in the basic template"
|
|
||||||
|
|
||||||
Examples: configs
|
|
||||||
| config_file |
|
|
||||||
| basic_onefile.yaml |
|
|
||||||
| basic_encrypted.yaml |
|
|
||||||
| basic_folder.yaml |
|
|
||||||
| basic_dayone.yaml |
|
|
||||||
|
|
||||||
|
|
||||||
@todo
|
|
||||||
Scenario Outline: --template file_in_XDG_templates_dir should be used in new entry
|
Scenario Outline: --template file_in_XDG_templates_dir should be used in new entry
|
||||||
Given we use the config "<config_file>"
|
Given we use the config "<config_file>"
|
||||||
And we use the password "test" if prompted
|
And we use the password "test" if prompted
|
||||||
|
And we copy the template "basic.template" to the default templates folder
|
||||||
When we run "jrnl --template basic.template"
|
When we run "jrnl --template basic.template"
|
||||||
And we run "jrnl -1"
|
Then the output should contain "No entry to save, because the template was not changed"
|
||||||
Then the output should contain "This text is in the basic template"
|
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
| config_file |
|
| config_file |
|
||||||
|
|
|
@ -89,6 +89,7 @@ def cli_run(
|
||||||
mock_user_input,
|
mock_user_input,
|
||||||
mock_overrides,
|
mock_overrides,
|
||||||
mock_default_journal_path,
|
mock_default_journal_path,
|
||||||
|
mock_default_templates_path,
|
||||||
):
|
):
|
||||||
# Check if we need more mocks
|
# Check if we need more mocks
|
||||||
mock_factories.update(mock_args)
|
mock_factories.update(mock_args)
|
||||||
|
@ -98,6 +99,7 @@ def cli_run(
|
||||||
mock_factories.update(mock_config_path)
|
mock_factories.update(mock_config_path)
|
||||||
mock_factories.update(mock_user_input)
|
mock_factories.update(mock_user_input)
|
||||||
mock_factories.update(mock_default_journal_path)
|
mock_factories.update(mock_default_journal_path)
|
||||||
|
mock_factories.update(mock_default_templates_path)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": 0,
|
"status": 0,
|
||||||
|
@ -179,6 +181,16 @@ def mock_default_journal_path(temp_dir):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def mock_default_templates_path(temp_dir):
|
||||||
|
templates_path = Path(temp_dir.name, "templates")
|
||||||
|
return {
|
||||||
|
"get_templates_path": lambda: patch(
|
||||||
|
"jrnl.controller.get_templates_path", return_value=templates_path
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
def temp_dir():
|
def temp_dir():
|
||||||
return tempfile.TemporaryDirectory()
|
return tempfile.TemporaryDirectory()
|
||||||
|
|
|
@ -125,6 +125,19 @@ def we_use_the_config(request, temp_dir, working_dir, config_file):
|
||||||
return config_dest
|
return config_dest
|
||||||
|
|
||||||
|
|
||||||
|
@given(parse('we copy the template "{template_file}" to the default templates folder'), target_fixture="default_templates_path")
|
||||||
|
def we_copy_the_template(request, temp_dir, working_dir, template_file):
|
||||||
|
# Move into temp dir as cwd
|
||||||
|
os.chdir(temp_dir.name) # @todo move this step to a more universal place
|
||||||
|
|
||||||
|
# Copy template over
|
||||||
|
template_source = os.path.join(working_dir, "data", "templates", template_file)
|
||||||
|
template_dest = os.path.join(temp_dir.name, "templates", template_file)
|
||||||
|
os.makedirs(os.path.dirname(template_dest), exist_ok=True)
|
||||||
|
shutil.copy2(template_source, template_dest)
|
||||||
|
return template_dest
|
||||||
|
|
||||||
|
|
||||||
@given(parse('the config "{config_file}" exists'), target_fixture="config_path")
|
@given(parse('the config "{config_file}" exists'), target_fixture="config_path")
|
||||||
def config_exists(config_file, temp_dir, working_dir):
|
def config_exists(config_file, temp_dir, working_dir):
|
||||||
config_source = os.path.join(working_dir, "data", "configs", config_file)
|
config_source = os.path.join(working_dir, "data", "configs", config_file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue