Skip to content

Commit 2f05bb2

Browse files
Adds reload webapp to the project.
1 parent 8bc297e commit 2f05bb2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pythonanywhere/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def __init__(self, domain, python_version):
2020
)
2121
self.webapp = Webapp(domain)
2222

23-
2423
def sanity_checks(self, nuke):
2524
self.webapp.sanity_checks(nuke=nuke)
2625
if nuke:
@@ -40,17 +39,18 @@ def sanity_checks(self, nuke):
4039
)
4140
)
4241

43-
4442
def create_webapp(self, nuke):
4543
print(snakesay("Creating web app via API"))
4644
self.webapp.create(self.python_version, self.virtualenv.path, self.project_path, nuke=nuke)
4745

46+
def reload_webapp(self):
47+
print(snakesay(f"Reloading web app on {self.domain}"))
48+
self.webapp.reload()
4849

4950
def add_static_file_mappings(self):
5051
print(snakesay("Adding static files mappings for /static/ and /media/"))
5152
self.webapp.add_default_static_files_mappings(self.project_path)
5253

53-
5454
def start_bash(self):
5555
print(snakesay('Starting Bash shell with activated virtualenv in project directory. Press Ctrl+D to exit.'))
5656
unique_id = str(uuid.uuid4())

tests/test_project.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ def test_add_static_file_mappings_calls_webapp_add_default_static_files_mappings
8989
)
9090

9191

92+
def test_reload_webapp_calls_webapp_reload(virtualenvs_folder, mocker):
93+
mock_webapp_class = mocker.patch('pythonanywhere.project.Webapp', autospec=True)
94+
project = Project('mydomain.com', 'python.version')
95+
project.reload_webapp()
96+
mock_webapp_class.return_value.reload.assert_called_once()
97+
98+
9299
def test_start_bash_calls_launch_bash_in_virtualenv_with_virtualenv_and_project_path(fake_home, virtualenvs_folder):
93100
project = Project('mydomain.com', 'python.version')
94101
with patch('pythonanywhere.project.launch_bash_in_virtualenv') as mock_launch_bash_in_virtualenv:

0 commit comments

Comments
 (0)