Clarify and cleanup tests

- Run formatter
- Take out old tags
- Use new steps on tests

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Jonathan Wren 2021-05-22 14:15:43 -07:00
parent 44b1762b7d
commit b7b7bad2fb
5 changed files with 44 additions and 25 deletions

View file

@ -164,6 +164,7 @@ def password():
def input_method():
return ""
@fixture
def now_date():
return {"datetime": datetime, "calendar_parse": __get_pdt_calendar()}
@ -373,7 +374,11 @@ def use_password_forever(pw):
@when(parse('we run "jrnl {command}" and {input_method}\n{user_input}'))
@when(parsers.re('we run "jrnl (?P<command>[^"]+)" and (?P<input_method>enter|pipe) "(?P<user_input>[^"]+)"'))
@when(
parsers.re(
'we run "jrnl (?P<command>[^"]+)" and (?P<input_method>enter|pipe) "(?P<user_input>[^"]+)"'
)
)
@when(parse('we run "jrnl" and {input_method} "{user_input}"'))
@when(parse('we run "jrnl {command}"'))
@when('we run "jrnl <command>"')
@ -391,8 +396,8 @@ def we_run(
keyring,
input_method,
):
assert input_method in ['', 'enter', 'pipe']
is_tty = input_method != 'pipe'
assert input_method in ["", "enter", "pipe"]
is_tty = input_method != "pipe"
if cache_dir["exists"]:
command = command.format(cache_dir=cache_dir["path"])
@ -573,6 +578,15 @@ def journal_directory_should_contain(config_data, file_list):
assert does_directory_contain_files(file_list, scoped_config["journal"])
@then(parse('journal "{journal_name}" should not exist'))
def journal_directory_should_contain(config_data, journal_name):
scoped_config = scope_config(config_data, journal_name)
assert not does_directory_contain_files(
scoped_config["journal"], "."
), f'Journal "{journal_name}" does exist'
@when(parse('we change directory to "{directory_name}"'))
def when_we_change_directory(directory_name):
if not os.path.isdir(directory_name):