Skip to content

Commit 7fd4072

Browse files
makes webapp creation without venv possible.
1 parent a2bc31d commit 7fd4072

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pythonanywhere_core/webapp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def sanity_checks(self, nuke: bool) -> None:
7474
f"You already have a webapp for {self.domain}.\n\nUse the --nuke option if you want to replace it."
7575
)
7676

77-
def create(self, python_version: str, virtualenv_path: Path, project_path: Path, nuke: bool) -> None:
77+
def create(self, python_version: str, virtualenv_path: Path | None, project_path: Path, nuke: bool) -> None:
7878
"""Create a webapp for the given domain, using the given python version and virtualenv path
7979
8080
:param python_version: python version to use
81-
:param virtualenv_path: path to the virtualenv
81+
:param virtualenv_path: path to the virtualenv, or None to skip setting it
8282
:param project_path: path to the project
8383
:param nuke: if True, delete any existing webapp for this domain
8484

tests/test_webapp.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ def test_raises_if_post_returns_a_200_with_status_error(api_responses, api_token
194194
assert "bad things happened" in str(e.value)
195195

196196

197+
def test_does_patch_without_virtualenv_path_when_none(
198+
api_responses, api_token, base_url, domain_url, webapp
199+
):
200+
api_responses.add(
201+
responses.POST,
202+
base_url,
203+
status=201,
204+
body=json.dumps({"status": "OK"}),
205+
)
206+
api_responses.add(responses.PATCH, domain_url, status=200)
207+
208+
webapp.create("3.10", virtualenv_path=None, project_path="/project/path", nuke=False)
209+
210+
patch = api_responses.calls[1]
211+
assert patch.request.url == domain_url
212+
assert patch.request.body == urlencode({"source_directory": "/project/path"})
213+
assert "virtualenv_path" not in patch.request.body
214+
215+
197216
def test_raises_if_patch_does_not_20x(api_responses, api_token, base_url, domain_url, webapp):
198217
api_responses.add(
199218
responses.POST,

0 commit comments

Comments
 (0)