Skip to content

Commit

Permalink
Add tests relevant to descriptions for arguments.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Michionlion committed Sep 17, 2021
1 parent eb41651 commit ac245cf
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ def test_basic_check_correct():
(["--json", "--nowelcome", "CheckCommits"]),
(["--nowelcome", "CheckCommits"]),
(["--checkerdir", "./gator/checks", "CheckCommits"]),
(["--description", "Are there 12 commits?", "CheckCommits"]),
(
[
"--checkerdir",
"./gator/checks",
"--description",
"Are there 18 commits?",
"CheckCommits",
]
),
(
[
"--json",
"--nowelcome",
"--checkerdir",
"./gator/checks",
"--description",
"Are there 18 commits?",
"CheckCommits",
]
),
],
)
def test_optional_commandline_arguments_can_verify(commandline_arguments):
Expand Down Expand Up @@ -80,6 +101,42 @@ def test_checkerdir_is_not_valid_arguments_verify(tmpdir):
assert args_verified is False


def test_description_is_valid_arguments_verify():
"""Check that command-line argument with valid string verifies."""
commandline_arguments = [
"--description",
"Do you have fake things?",
"check_FakeMessages",
]
gg_arguments, remaining_arguments = arguments.parse(commandline_arguments)
args_verified = arguments.verify(gg_arguments)
assert args_verified is True


def test_description_not_specified_is_not_valid_arguments_verify(capsys):
"""Check that command-line argument without valid string verifies."""
commandline_arguments = ["--description", "--json", "check_FakeMessages"]
with pytest.raises(SystemExit):
gg_arguments, remaining_arguments = arguments.parse(commandline_arguments)
_ = arguments.verify(gg_arguments)
captured = capsys.readouterr()
assert "--description: expected one argument" in captured.err


@pytest.mark.parametrize(
"commandline_arguments",
[
(["--description", "", "CheckCommits"]),
(["--description", 'Run the "check" check', "CheckCommits"]),
],
)
def test_description_is_not_valid_arguments_verify(commandline_arguments):
"""Check that command-line argument without valid string verifies."""
gg_arguments, remaining_arguments = arguments.parse(commandline_arguments)
args_verified = arguments.verify(gg_arguments)
assert args_verified is False


def test_help_produces_output(capsys):
"""Ensure that when given a request for help, it is produced correctly."""
with pytest.raises(SystemExit):
Expand Down

0 comments on commit ac245cf

Please sign in to comment.