Skip to content

Commit 341f486

Browse files
committed
#5 adds validation to pa schedule get tests and pytest marks to cli schedule tests. by: Piotr
1 parent db104cd commit 341f486

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_cli_schedule.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def mock_confirm(mocker):
3939
return mocker.patch("cli.schedule.typer.confirm")
4040

4141

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

7980

81+
@pytest.mark.clischeduledeleteall
8082
class TestDeleteAllTasks:
8183
def test_deletes_all_tasks_with_user_permission(self, task_list, mock_confirm):
8284
mock_confirm.return_value = True
@@ -113,6 +115,7 @@ def test_sets_logging_to_info(self, mocker):
113115
assert mock_logger.call_args == call(set_info=True)
114116

115117

118+
@pytest.mark.clischeduledelete
116119
class TestDeleteTaskById:
117120
def test_deletes_one_task(self, mocker):
118121
mock_task_from_id = mocker.patch("cli.schedule.get_task_from_id")
@@ -166,6 +169,7 @@ def task_from_id(mocker):
166169
yield task
167170

168171

172+
@pytest.mark.clischeduleget
169173
class TestGet:
170174
def test_logs_all_task_specs_using_tabulate(self, mocker, task_from_id):
171175
mock_tabulate = mocker.patch("cli.schedule.tabulate")
@@ -231,6 +235,11 @@ def test_logs_only_value_of_requested_task_spec(self, mocker, task_from_id):
231235
assert task_from_id.call_args == call(42)
232236
assert mock_logger.call_args == call(set_info=True)
233237
assert mock_logger.return_value.info.call_args == call("10:23")
238+
239+
def test_complains_when_no_id_provided(self):
240+
result = runner.invoke(app, ["get", "--command"])
241+
assert "Missing argument 'id'" in result.stdout
242+
234243
@pytest.mark.clischedulelist
235244
class TestList:
236245
def test_logs_table_with_correct_headers_and_values(self, mocker, task_list):

0 commit comments

Comments
 (0)