Skip to content

Commit

Permalink
#5 adds validation to pa schedule get tests and pytest marks to cli s…
Browse files Browse the repository at this point in the history
…chedule tests. by: Piotr
  • Loading branch information
caseneuve committed Jan 29, 2021
1 parent db104cd commit 341f486
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_cli_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def mock_confirm(mocker):
return mocker.patch("cli.schedule.typer.confirm")


@pytest.mark.clischeduleset
class TestSet:
def test_calls_all_stuff_in_right_order(self, mocker):
mock_logger = mocker.patch("cli.schedule.get_logger")
Expand Down Expand Up @@ -77,6 +78,7 @@ def test_validates_hours(self):
assert "66 is not in the valid range of 0 to 23" in result.stdout


@pytest.mark.clischeduledeleteall
class TestDeleteAllTasks:
def test_deletes_all_tasks_with_user_permission(self, task_list, mock_confirm):
mock_confirm.return_value = True
Expand Down Expand Up @@ -113,6 +115,7 @@ def test_sets_logging_to_info(self, mocker):
assert mock_logger.call_args == call(set_info=True)


@pytest.mark.clischeduledelete
class TestDeleteTaskById:
def test_deletes_one_task(self, mocker):
mock_task_from_id = mocker.patch("cli.schedule.get_task_from_id")
Expand Down Expand Up @@ -166,6 +169,7 @@ def task_from_id(mocker):
yield task


@pytest.mark.clischeduleget
class TestGet:
def test_logs_all_task_specs_using_tabulate(self, mocker, task_from_id):
mock_tabulate = mocker.patch("cli.schedule.tabulate")
Expand Down Expand Up @@ -231,6 +235,11 @@ def test_logs_only_value_of_requested_task_spec(self, mocker, task_from_id):
assert task_from_id.call_args == call(42)
assert mock_logger.call_args == call(set_info=True)
assert mock_logger.return_value.info.call_args == call("10:23")

def test_complains_when_no_id_provided(self):
result = runner.invoke(app, ["get", "--command"])
assert "Missing argument 'id'" in result.stdout

@pytest.mark.clischedulelist
class TestList:
def test_logs_table_with_correct_headers_and_values(self, mocker, task_list):
Expand Down

0 comments on commit 341f486

Please sign in to comment.