Skip to content

Commit

Permalink
#5 renames pa schedule 'create' subcommand to 'set'. by: Piotr
Browse files Browse the repository at this point in the history
  • Loading branch information
caseneuve committed Jan 29, 2021
1 parent 54eccd4 commit 9ab3966
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cli/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@app.command()
def create(
def set(
command: str = typer.Option(
..., "-c", "--command", help="Task's command to be scheduled"
),
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cli_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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

Expand Down

0 comments on commit 9ab3966

Please sign in to comment.