|
10 | 10 | import pythonanywhere.django_project
|
11 | 11 | from pythonanywhere.django_project import DjangoProject
|
12 | 12 | from pythonanywhere.exceptions import SanityException
|
13 |
| -from pythonanywhere.api import Webapp |
14 |
| -from pythonanywhere.virtualenvs import virtualenv_path |
15 |
| - |
16 |
| - |
17 |
| - |
18 |
| -class TestDjangoProject: |
19 |
| - |
20 |
| - def test_project_path(self, fake_home): |
21 |
| - project = DjangoProject('mydomain.com', 'python.version') |
22 |
| - assert project.project_path == fake_home / 'mydomain.com' |
23 |
| - |
24 |
| - |
25 |
| - def test_wsgi_file_path(self, fake_home): |
26 |
| - project = DjangoProject('mydomain.com', 'python.version') |
27 |
| - assert project.wsgi_file_path == '/var/www/mydomain_com_wsgi.py' |
28 |
| - |
29 |
| - |
30 |
| - def test_webapp(self, fake_home): |
31 |
| - project = DjangoProject('mydomain.com', 'python.version') |
32 |
| - assert project.webapp == Webapp('mydomain.com') |
33 |
| - |
34 |
| - |
35 |
| - def test_virtualenv_path(self, fake_home): |
36 |
| - project = DjangoProject('mydomain.com', 'python.version') |
37 |
| - assert project.virtualenv_path == virtualenv_path('mydomain.com') |
38 |
| - |
39 |
| - |
40 |
| - |
41 |
| -class TestSanityChecks: |
42 |
| - |
43 |
| - def test_calls_webapp_sanity_checks(self, fake_home): |
44 |
| - project = DjangoProject('mydomain.com', 'python.version') |
45 |
| - project.webapp.sanity_checks = Mock() |
46 |
| - project.sanity_checks(nuke='nuke.option') |
47 |
| - assert project.webapp.sanity_checks.call_args == call(nuke='nuke.option') |
48 |
| - |
49 |
| - |
50 |
| - def test_raises_if_virtualenv_exists(self, fake_home, virtualenvs_folder): |
51 |
| - project = DjangoProject('mydomain.com', 'python.version') |
52 |
| - project.webapp.sanity_checks = Mock() |
53 |
| - project.virtualenv_path.mkdir() |
54 |
| - |
55 |
| - with pytest.raises(SanityException) as e: |
56 |
| - project.sanity_checks(nuke=False) |
57 |
| - |
58 |
| - assert "You already have a virtualenv for mydomain.com" in str(e.value) |
59 |
| - as
F438
sert "nuke" in str(e.value) |
60 |
| - |
61 |
| - |
62 |
| - def test_raises_if_project_path_exists(self, fake_home, virtualenvs_folder): |
63 |
| - project = DjangoProject('mydomain.com', 'python.version') |
64 |
| - project.webapp.sanity_checks = Mock() |
65 |
| - project.project_path.mkdir() |
66 |
| - |
67 |
| - with pytest.raises(SanityException) as e: |
68 |
| - project.sanity_checks(nuke=False) |
69 |
| - |
70 |
| - expected_msg = f"You already have a project folder at {fake_home}/mydomain.com" |
71 |
| - assert expected_msg in str(e.value) |
72 |
| - assert "nuke" in str(e.value) |
73 |
| - |
74 |
| - |
75 |
| - def test_nuke_option_overrides_directory_checks(self, fake_home, virtualenvs_folder): |
76 |
| - project = DjangoProject('mydomain.com', 'python.version') |
77 |
| - project.webapp.sanity_checks = Mock() |
78 |
| - project.project_path.mkdir() |
79 |
| - project.virtualenv_path.mkdir() |
80 |
| - |
81 |
| - project.sanity_checks(nuke=True) # should not raise |
82 | 13 |
|
83 | 14 |
|
84 | 15 |
|
@@ -136,6 +67,7 @@ def test_if_requirements_txt_exists(self, fake_home):
|
136 | 67 | assert project.detect_django_version() == f'-r {requirements_txt.resolve()}'
|
137 | 68 |
|
138 | 69 |
|
| 70 | + |
139 | 71 | class TestCreateVirtualenv:
|
140 | 72 |
|
141 | 73 | def test_calls_create_virtualenv(self):
|
@@ -426,29 +358,3 @@ def test_actually_produces_wsgi_file_that_can_import_nested_project(
|
426 | 358 | print(open(project.wsgi_file_path).read())
|
427 | 359 | subprocess.check_output([project.virtualenv_path / 'bin/python', project.wsgi_file_path])
|
428 | 360 |
|
429 |
| - |
430 |
| - |
431 |
| - |
432 |
| -class TestCreateWebapp: |
433 |
| - |
434 |
| - def test_calls_webapp_create(self): |
435 |
| - project = DjangoProject('mydomain.com', 'python.version') |
436 |
| - project.webapp.create = Mock() |
437 |
| - |
438 |
| - project.create_webapp(nuke='nuke option') |
439 |
| - assert project.webapp.create.call_args == call( |
440 |
| - project.python_version, project.virtualenv_path, project.project_path, nuke='nuke option' |
441 |
| - ) |
442 |
| - |
443 |
| - |
444 |
| - |
445 |
| -class TestAddStaticFilesMappings: |
446 |
| - |
447 |
| - def test_calls_webapp_add_default_static_files_mappings(self): |
448 |
| - project = DjangoProject('mydomain.com', 'python.version') |
449 |
| - project.webapp.add_default_static_files_mappings = Mock() |
450 |
| - project.add_static_file_mappings() |
451 |
| - assert project.webapp.add_default_static_files_mappings.call_args == call( |
452 |
| - project.project_path, |
453 |
| - ) |
454 |
| - |
0 commit comments