@@ -20,6 +20,11 @@ def command():
2020 return "/usr/local/bin/uvicorn --uds $DOMAIN_SOCKET main:app"
2121
2222
23+ @pytest .fixture
24+ def mock_website (mocker ):
25+ return mocker .patch ("cli.website.Website" )
26+
27+
2328@pytest .fixture
2429def website_info (domain_name , command ):
2530 return {
@@ -80,8 +85,7 @@ def test_create_without_command_barfs():
8085 assert "Missing option" in result .stdout
8186
8287
83- def test_create_with_domain_and_command_creates_it (mocker ):
84- mock_website = mocker .patch ("cli.website.Website" )
88+ def test_create_with_domain_and_command_creates_it (mock_website ):
8589 result = runner .invoke (
8690 app ,
8791 [
@@ -100,8 +104,7 @@ def test_create_with_domain_and_command_creates_it(mocker):
100104 assert "All done!" in result .stdout
101105
102106
103- def test_get_with_no_domain_lists_websites (mocker , website_info ):
104- mock_website = mocker .patch ("cli.website.Website" )
107+ def test_get_with_no_domain_lists_websites (mocker , mock_website , website_info ):
105108 second_website_info = {"domain_name" : "blah.com" , "enabled" : False }
106109 mock_website .return_value .list .return_value = [website_info , second_website_info ]
107110 mock_tabulate = mocker .patch ("cli.website.tabulate" )
@@ -127,8 +130,7 @@ def test_get_with_no_domain_lists_websites(mocker, website_info):
127130 mock_echo .assert_called_once_with (mock_tabulate .return_value )
128131
129132
130- def test_get_with_domain_gives_details_for_domain (mocker , website_info , domain_name ):
131- mock_website = mocker .patch ("cli.website.Website" )
133+ def test_get_with_domain_gives_details_for_domain (mocker , mock_website , website_info , domain_name ):
132134 mock_website .return_value .get .return_value = website_info
133135 mock_tabulate = mocker .patch ("cli.website.tabulate" )
134136 mock_echo = mocker .patch ("cli.website.typer.echo" )
@@ -159,7 +161,7 @@ def test_get_with_domain_gives_details_for_domain(mocker, website_info, domain_n
159161
160162
161163def test_get_with_domain_gives_details_for_domain_even_without_logfiles (
162- mocker , domain_name , command
164+ mocker , domain_name , command , mock_website
163165):
164166 website_info = {
165167 "domain_name" : domain_name ,
@@ -177,7 +179,6 @@ def test_get_with_domain_gives_details_for_domain_even_without_logfiles(
177179 "id" : 42
178180 }
179181 }
180- mock_website = mocker .patch ("cli.website.Website" )
181182 mock_website .return_value .get .return_value = website_info
182183 mock_tabulate = mocker .patch ("cli.website.tabulate" )
183184 mock_echo = mocker .patch ("cli.website.typer.echo" )
@@ -215,8 +216,7 @@ def test_reload_with_no_domain_barfs():
215216 assert "Missing option" in result .stdout
216217
217218
218- def test_reload_with_domain_reloads (mocker ):
219- mock_website = mocker .patch ("cli.website.Website" )
219+ def test_reload_with_domain_reloads (mocker , mock_website ):
220220 mock_snakesay = mocker .patch ("cli.website.snakesay" )
221221 mock_echo = mocker .patch ("cli.website.typer.echo" )
222222
@@ -246,8 +246,7 @@ def test_delete_with_no_domain_barfs():
246246 assert "Missing option" in result .stdout
247247
248248
249- def test_delete_with_domain_deletes_it (mocker ):
250- mock_website = mocker .patch ("cli.website.Website" )
249+ def test_delete_with_domain_deletes_it (mocker , mock_website ):
251250 mock_snakesay = mocker .patch ("cli.website.snakesay" )
252251 mock_echo = mocker .patch ("cli.website.typer.echo" )
253252
0 commit comments