From 9ab3966e55c82bb5cb4648d47101298a488abde6 Mon Sep 17 00:00:00 2001 From: Piotr Kaznowski Date: Fri, 29 Jan 2021 16:22:46 +0100 Subject: [PATCH] #5 renames pa schedule 'create' subcommand to 'set'. by: Piotr --- cli/schedule.py | 6 +++--- tests/test_cli_schedule.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/schedule.py b/cli/schedule.py index 2c671b3..acace43 100644 --- a/cli/schedule.py +++ b/cli/schedule.py @@ -11,7 +11,7 @@ @app.command() -def create( +def set( command: str = typer.Option( ..., "-c", "--command", help="Task's command to be scheduled" ), @@ -45,11 +45,11 @@ def create( Example: Create a daily task to be run at 13:15: - pa schedule create --command "echo foo" --hour 13 --minute 15 + pa schedule set --command "echo foo" --hour 13 --minute 15 Create an inactive hourly task to be run 27 minutes past every hour: - pa schedule create --command "echo bar" --minute 27 --disabled + pa schedule set --command "echo bar" --minute 27 --disabled Note: Once task is created its behavior may be altered later on with diff --git a/tests/test_cli_schedule.py b/tests/test_cli_schedule.py index cd265e7..c1ef9f0 100644 --- a/tests/test_cli_schedule.py +++ b/tests/test_cli_schedule.py @@ -21,14 +21,14 @@ def mock_confirm(mocker): return mocker.patch("cli.schedule.typer.confirm") -class TestCreate: +class TestSet: def test_calls_all_stuff_in_right_order(self, mocker): mock_task_to_be_created = mocker.patch("cli.schedule.Task.to_be_created") runner.invoke( app, [ - "create", + "set", "--command", "echo foo", "--hour", @@ -46,13 +46,13 @@ def test_calls_all_stuff_in_right_order(self, mocker): ] def test_validates_minutes(self): - result = runner.invoke(app, ["create", "-c", "echo foo", "-h", "8", "-m", "66"]) + result = runner.invoke(app, ["set", "-c", "echo foo", "-h", "8", "-m", "66"]) assert "Invalid value" in result.stdout assert "66 is not in the valid range of 0 to 59" in result.stdout def test_validates_hours(self): - result = runner.invoke(app, ["create", "-c", "echo foo", "-h", "66", "-m", "1"]) + result = runner.invoke(app, ["set", "-c", "echo foo", "-h", "66", "-m", "1"]) assert "Invalid value" in result.stdout assert "66 is not in the valid range of 0 to 23" in result.stdout