mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
Update arg parsing to better handle optinal journal name
Fixes #520 -and parameter seems to only work for the default journal
This commit is contained in:
parent
bf6a66b245
commit
0bc5f9d453
3 changed files with 43 additions and 22 deletions
|
@ -78,7 +78,6 @@ def test_not_alone():
|
|||
assert cli_as_dict("-not test") == expected_args(excluded=["test"])
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_not_multiple_alone():
|
||||
assert cli_as_dict("-not one -not two") == expected_args(excluded=["one", "two"])
|
||||
assert cli_as_dict("-not one -not two -not three") == expected_args(
|
||||
|
@ -86,15 +85,24 @@ def test_not_multiple_alone():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"cli",
|
||||
["two -not one -not three", "-not one two -not three", "-not one -not three two",],
|
||||
)
|
||||
def test_not_mixed(cli):
|
||||
result = expected_args(excluded=["one", "three"], text=["two"])
|
||||
assert cli_as_dict(cli) == result
|
||||
|
||||
|
||||
def test_not_interspersed():
|
||||
result = expected_args(excluded=["one", "three"], text=["two", "two", "two"])
|
||||
assert cli_as_dict("two -not one two -not three two") == result
|
||||
|
||||
|
||||
def test_export_alone():
|
||||
assert cli_as_dict("--export json") == expected_args(export="json")
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_export_defaults_to_jrnl():
|
||||
assert cli_as_dict("--export") == expected_args(import_="jrnl")
|
||||
|
||||
|
||||
def test_import_alone():
|
||||
assert cli_as_dict("--import jrnl") == expected_args(import_="jrnl")
|
||||
|
||||
|
@ -165,20 +173,30 @@ def test_version_alone():
|
|||
|
||||
|
||||
# @see https://github.com/jrnl-org/jrnl/issues/520
|
||||
@pytest.mark.xfail
|
||||
def test_and_ordering():
|
||||
@pytest.mark.parametrize(
|
||||
"cli",
|
||||
[
|
||||
"-and second @oldtag @newtag",
|
||||
"second @oldtag @newtag -and",
|
||||
"second -and @oldtag @newtag",
|
||||
"second @oldtag -and @newtag",
|
||||
],
|
||||
)
|
||||
def test_and_ordering(cli):
|
||||
result = expected_args(strict=True, text=["second", "@oldtag", "@newtag"])
|
||||
assert result == cli_as_dict("-and second @oldtag @newtag")
|
||||
assert result == cli_as_dict("second @oldtag @newtag -and")
|
||||
assert result == cli_as_dict("second -and @oldtag @newtag")
|
||||
assert result == cli_as_dict("second @oldtag -and @newtag")
|
||||
assert cli_as_dict(cli) == result
|
||||
|
||||
|
||||
# @see https://github.com/jrnl-org/jrnl/issues/520
|
||||
@pytest.mark.xfail
|
||||
def test_edit_ordering():
|
||||
@pytest.mark.parametrize(
|
||||
"cli",
|
||||
[
|
||||
"--edit second @oldtag @newtag",
|
||||
"second @oldtag @newtag --edit",
|
||||
"second --edit @oldtag @newtag",
|
||||
"second @oldtag --edit @newtag",
|
||||
],
|
||||
)
|
||||
def test_edit_ordering(cli):
|
||||
result = expected_args(edit=True, text=["second", "@oldtag", "@newtag"])
|
||||
assert result == cli_as_dict("--edit second @oldtag @newtag")
|
||||
assert result == cli_as_dict("second @oldtag @newtag --edit")
|
||||
assert result == cli_as_dict("second --edit @oldtag @newtag")
|
||||
assert result == cli_as_dict("second @oldtag --edit @newtag")
|
||||
assert cli_as_dict(cli) == result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue