update version tests, add new regex match behave step

This commit is contained in:
Jonathan Wren 2020-09-19 12:50:58 -07:00
parent a6b646bb44
commit 899dd5037b
No known key found for this signature in database
GPG key ID: 43D5FF8722E7F68A
2 changed files with 35 additions and 7 deletions

View file

@ -1,15 +1,21 @@
Feature: Core functionality of jrnl outside of actually handling journals
Feature: Functionality of jrnl outside of actually handling journals
Scenario: Displaying the version number
Given we use the config "basic.yaml"
When we run "jrnl --version"
Then we should get no error
Then the output should match "^jrnl version v\d+\.\d+\.\d+(-(alpha|beta))?$"
Scenario: Displaying the version number
Given we use the config "basic.yaml"
When we run "jrnl -v"
Then we should get no error
Then the output should contain "version"
Then the output should match "^jrnl version v\d+\.\d+\.\d+(-(alpha|beta))?$"
Scenario: --diagnostic runs without exceptions
Scenario: Running the diagnostic command
When we run "jrnl --diagnostic"
Then the output should contain "jrnl"
And the output should contain "Python"
@todo
Scenario: --list outputs to user without exceptions
Scenario: Listing available journals

View file

@ -203,7 +203,7 @@ def contains_editor_arg(context, arg):
@then('one editor argument should match "{regex}"')
def matches_editor_arg(context, regex):
args = context.editor_command
matches = list(filter(lambda x: re.match(regex, x), args))
matches = list(filter(lambda x: re.search(regex, x), args))
assert (
len(matches) == 1
), f"\nRegex didn't match exactly 1 time:\n{regex}\n{str(args)}"
@ -406,6 +406,26 @@ def check_error_output_inline(context, text=None, text2=None):
assert text in out or text2 in out, text or text2
@then('the output should match "{regex}"')
@then('the output should match "{regex}" {num} times')
def matches_std_output(context, regex, num=1):
out = context.stdout_capture.getvalue()
matches = re.findall(regex, out)
assert (
matches and len(matches) == num
), f"\nRegex didn't match exactly {num} time(s):\n{regex}\n{str(out)}\n{str(matches)}"
@then('the error output should match "{regex}"')
@then('the error output should match "{regex}" {num} times')
def matches_err_ouput(context, regex, num=1):
out = context.stderr_capture.getvalue()
matches = re.findall(regex, out)
assert (
matches and len(matches) == num
), f"\nRegex didn't match exactly {num} time(s):\n{regex}\n{str(out)}\n{str(matches)}"
@then('the output should not contain "{text}"')
def check_output_not_inline(context, text):
out = context.stdout_capture.getvalue()
@ -438,7 +458,7 @@ def check_not_journal_content(context, text, journal_name="default"):
assert text not in journal, journal
@then('the journal should not exist')
@then("the journal should not exist")
@then('journal "{journal_name}" should not exist')
def journal_doesnt_exist(context, journal_name="default"):
config = load_config(install.CONFIG_FILE_PATH)
@ -446,7 +466,8 @@ def journal_doesnt_exist(context, journal_name="default"):
journal_path = config["journals"][journal_name]
assert not os.path.exists(journal_path)
@then('the journal should exist')
@then("the journal should exist")
@then('journal "{journal_name}" should exist')
def journal_exists(context, journal_name="default"):
config = load_config(install.CONFIG_FILE_PATH)
@ -454,6 +475,7 @@ def journal_exists(context, journal_name="default"):
journal_path = config["journals"][journal_name]
assert os.path.exists(journal_path)
@then('the config should have "{key}" set to')
@then('the config should have "{key}" set to "{value}"')
@then('the config for journal "{journal}" should have "{key}" set to "{value}"')