def test_updates_wsgi_file_from_template(self): project = DjangoProject('mydomain.com', 'python.version') project.wsgi_file_path = Path(tempfile.NamedTemporaryFile().name) project.settings_path = Path('/path/to/settingsfolder/settings.py') template = (Path(pythonanywhere.django_project.__file__).parent / 'wsgi_file_template.py').open().read() project.update_wsgi_file() with project.wsgi_file_path.open() as f: contents = f.read() print(contents) assert contents == template.format(project=project)
def test_actually_produces_wsgi_file_that_can_import_nested_project( self, fake_home, more_nested_submodule, virtualenvs_folder): project = DjangoProject('mydomain.com', '3.6') shutil.copytree(str(more_nested_submodule), str(project.project_path)) project.create_virtualenv() project.find_django_files() project.wsgi_file_path = Path(tempfile.NamedTemporaryFile().name) project.update_wsgi_file() print(project.wsgi_file_path.open().read()) subprocess.check_output([ str(project.virtualenv.path / 'bin/python'), str(project.wsgi_file_path) ])
def test_actually_produces_wsgi_file_that_can_import_nested_project( self, fake_home, more_nested_submodule, virtualenvs_folder): running_python_version = ".".join(python_version().split(".")[:2]) project = DjangoProject("mydomain.com", running_python_version) shutil.copytree(str(more_nested_submodule), str(project.project_path)) if running_python_version in ["3.7", "3.8"]: project.create_virtualenv(django_version="latest") else: project.create_virtualenv() project.find_django_files() project.wsgi_file_path = Path(tempfile.NamedTemporaryFile().name) project.update_wsgi_file() print(project.wsgi_file_path.open().read()) subprocess.check_output([ str(project.virtualenv.path / "bin/python"), str(project.wsgi_file_path) ])