Skip to content

Commit fa37a7a

Browse files
committed
PA-752: Missed some changes in the last commit. By Nina, Sam
1 parent 43181b7 commit fa37a7a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pythonanywhere-core"
3-
version = "0.2.1"
3+
version = "0.2.3"
44
description = "API wrapper for programmatic management of PythonAnywhere services."
55
authors = ["PythonAnywhere <[email protected]>"]
66
license = "MIT"

pythonanywhere_core/website.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ def sanity_check(self, domain_name: str, nuke: bool = False) -> None:
5858
)
5959

6060

61-
def create(self, domain_name: str, command: str) -> dict:
61+
def create(self, domain_name: str, command: str, nuke: bool = False) -> dict:
6262
"""Creates new website with ``domain_name`` and ``command``.
6363
6464
:param domain_name: domain name for new website
6565
:param command: command for new website
6666
:returns: dictionary with created website info"""
6767

68+
self.sanity_check(domain_name, nuke)
69+
6870
response = call_api(
6971
self.websites_base_url,
7072
"post",

tests/test_website.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55
import responses
6+
from unittest.mock import patch
67

78
from pythonanywhere_core.base import get_api_endpoint
89
from pythonanywhere_core.exceptions import PythonAnywhereApiException
@@ -188,3 +189,11 @@ def test_website_sanity_check_tests_api_token_present(api_responses, websites_ba
188189
Website().sanity_check(domain_name=domain_name, nuke=False)
189190

190191
assert "Could not find your API token" in str(e.value)
192+
193+
194+
@patch('pythonanywhere_core.website.Website.sanity_check')
195+
def test_create_website_calls_sanity_check(mock_sanity_check, api_responses, websites_base_url, website_info, domain_name, command):
196+
mock_sanity_check.side_effect = SanityException('Boom!')
197+
198+
with pytest.raises(SanityException):
199+
Website().create(domain_name=domain_name, command=command, nuke=False)

0 commit comments

Comments
 (0)