Skip to content

Commit e48738f

Browse files
committed
PA-655 delete domain from command line. by: Filip, Giles
1 parent 2e60767 commit e48738f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

cli/website.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def reload(
9292
):
9393
"""Reload the website at the given domain"""
9494
Website().reload(domain_name=domain_name)
95-
typer.echo(snakesay(f"Website {domain_name} reloaded!"))
95+
typer.echo(snakesay(f"Website {domain_name} has been reloaded!"))
9696

9797

9898
@app.command()
@@ -107,4 +107,5 @@ def delete(
107107
],
108108
):
109109
"""Delete the website at the given domain"""
110-
pass
110+
Website().delete(domain_name=domain_name)
111+
typer.echo(snakesay(f"Website {domain_name} has been deleted!"))

tests/test_cli_website.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_reload_with_domain_reloads(mocker):
185185

186186
assert result.exit_code == 0
187187
mock_website.return_value.reload.assert_called_once_with(domain_name="www.domain.com")
188-
mock_snakesay.assert_called_once_with(f"Website www.domain.com reloaded!")
188+
mock_snakesay.assert_called_once_with(f"Website www.domain.com has been reloaded!")
189189
mock_echo.assert_called_once_with(mock_snakesay.return_value)
190190

191191

@@ -200,7 +200,11 @@ def test_delete_with_no_domain_barfs():
200200
assert "Missing option" in result.stdout
201201

202202

203-
def test_delete_with_domain_deletes_it():
203+
def test_delete_with_domain_deletes_it(mocker):
204+
mock_website = mocker.patch("cli.website.Website")
205+
mock_snakesay = mocker.patch("cli.website.snakesay")
206+
mock_echo = mocker.patch("cli.website.typer.echo")
207+
204208
result = runner.invoke(
205209
app,
206210
[
@@ -209,5 +213,9 @@ def test_delete_with_domain_deletes_it():
209213
"www.domain.com",
210214
],
211215
)
216+
212217
assert result.exit_code == 0
213-
assert False, "TODO"
218+
mock_website.return_value.delete.assert_called_once_with(domain_name="www.domain.com")
219+
mock_snakesay.assert_called_once_with(f"Website www.domain.com has been deleted!")
220+
mock_echo.assert_called_once_with(mock_snakesay.return_value)
221+

0 commit comments

Comments
 (0)