mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Expand "we run" step to handling input better
- Use regex parser in pytest-bdd to support "we run" steps that also have user input ("and enter") Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
e720430aa4
commit
3d3bd91700
2 changed files with 21 additions and 2 deletions
|
@ -103,3 +103,20 @@ Feature: Using the installed keyring
|
|||
2013-06-09 15:39 My first entry.
|
||||
2013-06-10 15:40 Life is good.
|
||||
|
||||
|
||||
Scenario: Mistyping your password, then getting it right
|
||||
Given we use the config "simple.yaml"
|
||||
When we run "jrnl --encrypt" and enter
|
||||
swordfish
|
||||
sordfish
|
||||
swordfish
|
||||
swordfish
|
||||
n
|
||||
Then we should be prompted for a password
|
||||
And we should see the message "Passwords did not match"
|
||||
And we should see the message "Journal encrypted"
|
||||
And the config for journal "default" should have "encrypt" set to "bool:True"
|
||||
When we run "jrnl -1" and enter "swordfish"
|
||||
Then we should be prompted for a password
|
||||
And the output should contain "2013-06-10 15:40 Life is good"
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from pytest_bdd import given
|
|||
from pytest_bdd import then
|
||||
from pytest_bdd import when
|
||||
from pytest_bdd.parsers import parse
|
||||
from pytest_bdd import parsers
|
||||
from pytest import fixture
|
||||
import toml
|
||||
|
||||
|
@ -205,11 +206,12 @@ def use_password_forever(pw):
|
|||
return pw
|
||||
|
||||
|
||||
@when(parse('we run "jrnl {command}" and enter\n{user_input}'))
|
||||
@when(parsers.re('we run "jrnl (?P<command>[^"]+)" and enter "(?P<user_input>[^"]+)"'))
|
||||
@when(parse('we run "jrnl {command}"'))
|
||||
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
||||
@when('we run "jrnl <command>"')
|
||||
@when('we run "jrnl"')
|
||||
@when(parse('we run "jrnl" and enter "{user_input}"'))
|
||||
@when(parse('we run "jrnl {command}" and enter\n{user_input}'))
|
||||
def we_run(command, config_path, user_input, cli_run, capsys, password, keyring):
|
||||
args = split_args(command)
|
||||
status = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue