diff --git a/readthedocs/core/views/__init__.py b/readthedocs/core/views/__init__.py index 61e5b6e71f5..8fcccb749fb 100644 --- a/readthedocs/core/views/__init__.py +++ b/readthedocs/core/views/__init__.py @@ -14,13 +14,12 @@ from django.http import HttpResponseRedirect, Http404, JsonResponse from django.shortcuts import render, get_object_or_404, redirect from django.views.generic import TemplateView - +from django.views.static import serve as static_serve from readthedocs.builds.models import Version from readthedocs.core.utils.general import wipe_version_via_slugs from readthedocs.core.resolver import resolve_path from readthedocs.core.symlink import PrivateSymlink, PublicSymlink -from readthedocs.core.views.serve import _serve_file from readthedocs.projects.constants import PRIVATE from readthedocs.projects.models import HTMLFile, Project from readthedocs.redirects.utils import ( @@ -205,7 +204,7 @@ def resolve_404_path(project, version_slug=None, language=None): project.slug, slug, ) - r = _serve_file(request, filename, basepath) + r = static_serve(request, filename, basepath) r.status_code = 404 return r diff --git a/readthedocs/rtd_tests/tests/test_doc_serving.py b/readthedocs/rtd_tests/tests/test_doc_serving.py index d2ed7adf166..0eb938a70ee 100644 --- a/readthedocs/rtd_tests/tests/test_doc_serving.py +++ b/readthedocs/rtd_tests/tests/test_doc_serving.py @@ -201,14 +201,11 @@ def test_custom_robots_txt(self, os_mock, open_mock): ROOT_URLCONF=settings.SUBDOMAIN_URLCONF, ) - @patch('readthedocs.core.views.serve.os') + @patch('readthedocs.core.views.static_serve') @patch('readthedocs.core.views.os') - def test_custom_404_page(self, os_view_mock, os_serve_mock): + def test_custom_404_page(self, os_view_mock, static_serve_mock): os_view_mock.path.exists.return_value = True - os_serve_mock.path.join.side_effect = os.path.join - os_serve_mock.path.exists.return_value = True - self.public.versions.update(active=True, built=True) factory = RequestFactory() @@ -221,7 +218,6 @@ def test_custom_404_page(self, os_view_mock, os_serve_mock): middleware.process_request(request) response = server_error_404_subdomain(request) self.assertEqual(response.status_code, 404) - self.assertTrue(response['X-Accel-Redirect'].endswith('/public/en/latest/404.html')) @override_settings( USE_SUBDOMAIN=True,