diff --git a/docs/dev/install.rst b/docs/dev/install.rst index 0db108bc574..ef5685819c6 100644 --- a/docs/dev/install.rst +++ b/docs/dev/install.rst @@ -346,7 +346,7 @@ Docker for builds Serve documentation under a subdomain There are a number of resolution bugs and cross-domain behavior that can - only be caught by using `USE_SUBDOMAIN` setting. + only be caught by using a ``PUBLIC_DOMAIN`` setting different from the ``PRODUCTION_DOMAIN`` setting. PostgreSQL as a database It is recommended that Postgres be used as the default database whenever diff --git a/docs/dev/settings.rst b/docs/dev/settings.rst index 401cb8b61ba..2e9177a0653 100644 --- a/docs/dev/settings.rst +++ b/docs/dev/settings.rst @@ -19,18 +19,10 @@ memory Examples: '200m' for 200MB of total memory, or '2g' for 2GB of total memory. -USE_SUBDOMAIN ---------------- - -Whether to use subdomains in URLs on the site, or the Django-served content. -When used in production, this should be ``True``, as Nginx will serve this content. -During development and other possible deployments, this might be ``False``. - PRODUCTION_DOMAIN ------------------ -This is the domain that gets linked to throughout the site when used in production. -It depends on `USE_SUBDOMAIN`, otherwise it isn't used. +This is the domain that is used by the main application dashboard (not documentation pages). RTD_INTERSPHINX_URL ------------------- diff --git a/readthedocs/api/v3/tests/mixins.py b/readthedocs/api/v3/tests/mixins.py index 4dceea92c38..8dfb7cf1b7d 100644 --- a/readthedocs/api/v3/tests/mixins.py +++ b/readthedocs/api/v3/tests/mixins.py @@ -21,7 +21,6 @@ @override_settings( PUBLIC_DOMAIN="readthedocs.io", PRODUCTION_DOMAIN="readthedocs.org", - USE_SUBDOMAIN=True, RTD_BUILD_MEDIA_STORAGE="readthedocs.rtd_tests.storage.BuildMediaFileSystemStorageTest", RTD_ALLOW_ORGANIZATIONS=False, ) diff --git a/readthedocs/core/context_processors.py b/readthedocs/core/context_processors.py index 8bd60e352ee..36653823509 100644 --- a/readthedocs/core/context_processors.py +++ b/readthedocs/core/context_processors.py @@ -7,7 +7,6 @@ def readthedocs_processor(request): exports = { "PUBLIC_DOMAIN": settings.PUBLIC_DOMAIN, "PRODUCTION_DOMAIN": settings.PRODUCTION_DOMAIN, - "USE_SUBDOMAIN": settings.USE_SUBDOMAIN, "GLOBAL_ANALYTICS_CODE": settings.GLOBAL_ANALYTICS_CODE, "DASHBOARD_ANALYTICS_CODE": settings.DASHBOARD_ANALYTICS_CODE, "SITE_ROOT": settings.SITE_ROOT + "/", diff --git a/readthedocs/core/resolver.py b/readthedocs/core/resolver.py index dc6cf0ffae2..dd90dc2282c 100644 --- a/readthedocs/core/resolver.py +++ b/readthedocs/core/resolver.py @@ -62,8 +62,6 @@ def base_resolve_path( language=None, single_version=None, project_relationship=None, - subdomain=None, - cname=None, custom_prefix=None, ): """ @@ -77,12 +75,7 @@ def base_resolve_path( the path will be prefixed with the subproject prefix (defaults to ``/projects//``). """ - # Only support `/docs/project' URLs outside our normal environment. Normally - # the path should always have a subdomain or CNAME domain - if subdomain or cname or self._use_subdomain(): - path = "/" - else: - path = "/docs/{project}/" + path = "/" if project_relationship: path = unsafe_join_url_path(path, project_relationship.subproject_prefix) @@ -112,8 +105,6 @@ def resolve_path( version_slug=None, language=None, single_version=None, - subdomain=None, - cname=None, ): """Resolve a URL with a subset of fields defined.""" version_slug = version_slug or project.get_default_version() @@ -122,11 +113,6 @@ def resolve_path( filename = self._fix_filename(filename) parent_project, project_relationship = self._get_canonical_project_data(project) - cname = ( - cname - or self._use_subdomain() - or parent_project.get_canonical_custom_domain() - ) single_version = bool(project.single_version or single_version) # If the project is a subproject, we use the custom prefix @@ -145,8 +131,6 @@ def resolve_path( language=language, single_version=single_version, project_relationship=project_relationship, - cname=cname, - subdomain=subdomain, custom_prefix=custom_prefix, ) @@ -163,10 +147,7 @@ def resolve_domain(self, project, use_canonical_domain=True): if domain: return domain.domain - if self._use_subdomain(): - return self._get_project_subdomain(canonical_project) - - return settings.PRODUCTION_DOMAIN + return self._get_project_subdomain(canonical_project) def resolve( self, @@ -192,10 +173,8 @@ def resolve( domain = self._get_external_subdomain(canonical_project, version_slug) elif use_custom_domain: domain = custom_domain.domain - elif self._use_subdomain(): - domain = self._get_project_subdomain(canonical_project) else: - domain = settings.PRODUCTION_DOMAIN + domain = self._get_project_subdomain(canonical_project) use_https_protocol = any( [ @@ -383,10 +362,6 @@ def _use_custom_domain(self, custom_domain): """ return custom_domain is not None - def _use_subdomain(self): - """Make decision about whether to use a subdomain to serve docs.""" - return settings.USE_SUBDOMAIN and settings.PUBLIC_DOMAIN is not None - def _use_cname(self, project): """Test if to allow direct serving for project on CNAME.""" return bool(get_feature(project, feature_type=TYPE_CNAME)) diff --git a/readthedocs/embed/tests/test_api.py b/readthedocs/embed/tests/test_api.py index 1fd534e610e..50be6c5dd18 100644 --- a/readthedocs/embed/tests/test_api.py +++ b/readthedocs/embed/tests/test_api.py @@ -33,7 +33,6 @@ def setup_method(self, settings): self.version.privacy_level = PUBLIC self.version.save() - settings.USE_SUBDOMAIN = True settings.PUBLIC_DOMAIN = "readthedocs.io" settings.RTD_DEFAULT_FEATURES = dict( [RTDProductFeature(TYPE_EMBED_API).to_item()] diff --git a/readthedocs/embed/v3/tests/test_access.py b/readthedocs/embed/v3/tests/test_access.py index 0b6a17d0280..906a3e123d9 100644 --- a/readthedocs/embed/v3/tests/test_access.py +++ b/readthedocs/embed/v3/tests/test_access.py @@ -17,7 +17,6 @@ @override_settings( - USE_SUBDOMAIN=True, PUBLIC_DOMAIN="readthedocs.io", RTD_ALLOW_ORGAZATIONS=False, RTD_DEFAULT_FEATURES=dict([RTDProductFeature(TYPE_EMBED_API).to_item()]), diff --git a/readthedocs/embed/v3/tests/test_basics.py b/readthedocs/embed/v3/tests/test_basics.py index bd21a7a408c..5d77e9219f8 100644 --- a/readthedocs/embed/v3/tests/test_basics.py +++ b/readthedocs/embed/v3/tests/test_basics.py @@ -9,7 +9,6 @@ class TestEmbedAPIv3Basics: @pytest.fixture(autouse=True) def setup_method(self, settings): - settings.USE_SUBDOMAIN = True settings.PUBLIC_DOMAIN = "readthedocs.io" settings.RTD_EMBED_API_EXTERNAL_DOMAINS = ["docs.project.com"] diff --git a/readthedocs/embed/v3/tests/test_external_pages.py b/readthedocs/embed/v3/tests/test_external_pages.py index 28649deaf22..c1f9c88dcdd 100644 --- a/readthedocs/embed/v3/tests/test_external_pages.py +++ b/readthedocs/embed/v3/tests/test_external_pages.py @@ -13,7 +13,6 @@ class TestEmbedAPIv3ExternalPages: @pytest.fixture(autouse=True) def setup_method(self, settings): - settings.USE_SUBDOMAIN = True settings.PUBLIC_DOMAIN = "readthedocs.io" settings.RTD_EMBED_API_EXTERNAL_DOMAINS = ["docs.project.com"] diff --git a/readthedocs/embed/v3/tests/test_internal_pages.py b/readthedocs/embed/v3/tests/test_internal_pages.py index 95b169b4121..69bc1c2851b 100644 --- a/readthedocs/embed/v3/tests/test_internal_pages.py +++ b/readthedocs/embed/v3/tests/test_internal_pages.py @@ -20,7 +20,6 @@ class TestEmbedAPIv3InternalPages: @pytest.fixture(autouse=True) def setup_method(self, settings): - settings.USE_SUBDOMAIN = True settings.PUBLIC_DOMAIN = "readthedocs.io" settings.RTD_EMBED_API_EXTERNAL_DOMAINS = [] settings.RTD_DEFAULT_FEATURES = dict( diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index b6387ff895d..c7ac8f0b7e2 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -755,11 +755,7 @@ def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) # Get the default docs domain - ctx['default_domain'] = ( - settings.PUBLIC_DOMAIN - if settings.USE_SUBDOMAIN - else settings.PRODUCTION_DOMAIN - ) + ctx["default_domain"] = settings.PUBLIC_DOMAIN return ctx diff --git a/readthedocs/proxito/middleware.py b/readthedocs/proxito/middleware.py index d009af88570..16db0ec3769 100644 --- a/readthedocs/proxito/middleware.py +++ b/readthedocs/proxito/middleware.py @@ -200,12 +200,7 @@ def process_request(self, request): # noqa request.unresolved_domain = None skip = any(request.path.startswith(reverse(view)) for view in self.skip_views) - if ( - skip - or not settings.USE_SUBDOMAIN - or "localhost" in request.get_host() - or "testserver" in request.get_host() - ): + if skip: log.debug("Not processing Proxito middleware") return None diff --git a/readthedocs/proxito/tests/test_old_redirects.py b/readthedocs/proxito/tests/test_old_redirects.py index b9d420a1f62..85b0aab6b1a 100644 --- a/readthedocs/proxito/tests/test_old_redirects.py +++ b/readthedocs/proxito/tests/test_old_redirects.py @@ -6,7 +6,6 @@ and adapted to use: * El Proxito - * USE_SUBDOMAIN=True always """ import django_dynamic_fixture as fixture diff --git a/readthedocs/rtd_tests/tests/test_api.py b/readthedocs/rtd_tests/tests/test_api.py index 961252ea9fd..3ae6d4752b5 100644 --- a/readthedocs/rtd_tests/tests/test_api.py +++ b/readthedocs/rtd_tests/tests/test_api.py @@ -65,6 +65,7 @@ from readthedocs.subscriptions.products import RTDProductFeature +@override_settings(PUBLIC_DOMAIN="readthedocs.io") class APIBuildTests(TestCase): fixtures = ['eric.json', 'test_data.json'] @@ -253,15 +254,12 @@ def test_response_finished_and_success(self): resp = client.get('/api/v2/build/{build}/'.format(build=build.pk)) self.assertEqual(resp.status_code, 200) build = resp.data - docs_url = 'http://readthedocs.org/docs/{project}/en/{version}/'.format( - project=project.slug, - version=version.slug, - ) - self.assertEqual(build['state'], 'finished') - self.assertEqual(build['error'], '') - self.assertEqual(build['exit_code'], 0) - self.assertEqual(build['success'], True) - self.assertEqual(build['docs_url'], docs_url) + docs_url = f"http://{project.slug}.readthedocs.io/en/{version.slug}/" + self.assertEqual(build["state"], "finished") + self.assertEqual(build["error"], "") + self.assertEqual(build["exit_code"], 0) + self.assertEqual(build["success"], True) + self.assertEqual(build["docs_url"], docs_url) # Verify the path is trimmed self.assertEqual( build["commands"][0]["command"], @@ -3108,6 +3106,7 @@ def test_webhook_build_another_branch(self, trigger_build): self.assertEqual(resp.data['versions'], ['v1.0']) +@override_settings(PUBLIC_DOMAIN="readthedocs.io") class APIVersionTests(TestCase): fixtures = ['eric', 'test_data'] maxDiff = None # So we get an actual diff when it fails @@ -3139,11 +3138,11 @@ def test_get_version_by_id(self): "built": False, "id": 18, "active": True, - "canonical_url": "http://readthedocs.org/docs/pip/en/0.8/", + "canonical_url": "http://pip.readthedocs.io/en/0.8/", "project": { "analytics_code": None, "analytics_disabled": False, - "canonical_url": "http://readthedocs.org/docs/pip/en/latest/", + "canonical_url": "http://pip.readthedocs.io/en/latest/", "cdn_enabled": False, "conf_py_file": "", "container_image": None, @@ -3203,7 +3202,7 @@ def test_get_active_versions(self): 'active': 'true', } url = reverse("version-list") - with self.assertNumQueries(6): + with self.assertNumQueries(5): resp = self.client.get(url, data) self.assertEqual(resp.status_code, 200) @@ -3213,7 +3212,7 @@ def test_get_active_versions(self): data.update({ 'active': 'false', }) - with self.assertNumQueries(6): + with self.assertNumQueries(5): resp = self.client.get(url, data) self.assertEqual(resp.status_code, 200) self.assertEqual(resp.data['count'], pip.versions.filter(active=False).count()) @@ -3221,7 +3220,7 @@ def test_get_active_versions(self): def test_project_get_active_versions(self): pip = Project.objects.get(slug="pip") url = reverse("project-active-versions", args=[pip.pk]) - with self.assertNumQueries(6): + with self.assertNumQueries(5): resp = self.client.get(url) self.assertEqual( len(resp.data["versions"]), pip.versions.filter(active=True).count() diff --git a/readthedocs/rtd_tests/tests/test_build_notifications.py b/readthedocs/rtd_tests/tests/test_build_notifications.py index bfed6b612a1..f9c8d654bf7 100644 --- a/readthedocs/rtd_tests/tests/test_build_notifications.py +++ b/readthedocs/rtd_tests/tests/test_build_notifications.py @@ -25,7 +25,6 @@ @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) class BuildNotificationsTests(TestCase): def setUp(self): diff --git a/readthedocs/rtd_tests/tests/test_core_tags.py b/readthedocs/rtd_tests/tests/test_core_tags.py index 01ddf3c2450..44d7cfe0dad 100644 --- a/readthedocs/rtd_tests/tests/test_core_tags.py +++ b/readthedocs/rtd_tests/tests/test_core_tags.py @@ -7,12 +7,12 @@ from readthedocs.projects.models import Project -@override_settings(USE_SUBDOMAIN=False, PRODUCTION_DOMAIN="readthedocs.org") +@override_settings(PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.org") class CoreTagsTests(TestCase): fixtures = ["eric", "test_data"] def setUp(self): - url_base = "http://{domain}/docs/pip{{version}}".format( + url_base = "http://pip.{domain}{{version}}".format( domain=settings.PRODUCTION_DOMAIN, ) diff --git a/readthedocs/rtd_tests/tests/test_footer.py b/readthedocs/rtd_tests/tests/test_footer.py index a7cde5acf99..c54b1a2155a 100644 --- a/readthedocs/rtd_tests/tests/test_footer.py +++ b/readthedocs/rtd_tests/tests/test_footer.py @@ -325,7 +325,6 @@ class TestFooterHTML(BaseTestFooterHTML, TestCase): @override_settings( - USE_SUBDOMAIN=True, PUBLIC_DOMAIN="readthedocs.io", PUBLIC_DOMAIN_USES_HTTPS=True, ) diff --git a/readthedocs/rtd_tests/tests/test_notifications.py b/readthedocs/rtd_tests/tests/test_notifications.py index 4a94787b812..b0db76046a2 100644 --- a/readthedocs/rtd_tests/tests/test_notifications.py +++ b/readthedocs/rtd_tests/tests/test_notifications.py @@ -71,7 +71,6 @@ class TestNotification(Notification): "SUPPORT_EMAIL": "support@readthedocs.org", "TEMPLATE_ROOT": mock.ANY, "USE_PROMOS": mock.ANY, - "USE_SUBDOMAIN": mock.ANY, "USE_ORGANIZATIONS": mock.ANY, }, ) @@ -236,7 +235,6 @@ def test_context_data(self): "SUPPORT_EMAIL": "support@readthedocs.org", "TEMPLATE_ROOT": mock.ANY, "USE_PROMOS": mock.ANY, - "USE_SUBDOMAIN": mock.ANY, "USE_ORGANIZATIONS": mock.ANY, } self.assertEqual(self.n.get_context_data(), context) diff --git a/readthedocs/rtd_tests/tests/test_privacy.py b/readthedocs/rtd_tests/tests/test_privacy.py index ade17dbb395..4014bf08ac2 100644 --- a/readthedocs/rtd_tests/tests/test_privacy.py +++ b/readthedocs/rtd_tests/tests/test_privacy.py @@ -227,7 +227,6 @@ def test_private_public_repo_downloading(self): @override_settings( DEFAULT_PRIVACY_LEVEL="private", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_private_download_filename(self): self._create_kong("private", "private") @@ -270,7 +269,6 @@ def test_private_download_filename(self): @override_settings( DEFAULT_PRIVACY_LEVEL="public", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_public_repo_downloading(self): self._create_kong("public", "public") @@ -308,7 +306,6 @@ def test_public_repo_downloading(self): @override_settings( DEFAULT_PRIVACY_LEVEL="public", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_public_private_repo_downloading(self): self._create_kong("private", "private") @@ -338,7 +335,6 @@ def test_public_private_repo_downloading(self): @override_settings( DEFAULT_PRIVACY_LEVEL="public", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_public_download_filename(self): self._create_kong("public", "public") diff --git a/readthedocs/rtd_tests/tests/test_redirects.py b/readthedocs/rtd_tests/tests/test_redirects.py index 4660565bf9b..9925147d917 100644 --- a/readthedocs/rtd_tests/tests/test_redirects.py +++ b/readthedocs/rtd_tests/tests/test_redirects.py @@ -7,75 +7,6 @@ from readthedocs.redirects.models import Redirect -# TODO: most of these tests are using USE_SUBDOMAIN, which is not supported anymore. -# Besides, most (or all of them) were migrated to ``readthedocs/proxito/tests/test_old_redirects.py`` -# and they are using the correct settings (mocked storage to return correct value on ``.exists()``) -# These tests could be removed completely in the near future. -@override_settings( - PUBLIC_DOMAIN="readthedocs.org", USE_SUBDOMAIN=False, APPEND_SLASH=False -) -class RedirectTests(TestCase): - fixtures = ["eric", "test_data"] - - def setUp(self): - self.client.login(username="eric", password="test") - pip = Project.objects.get(slug="pip") - pip.versions.create_latest() - - def test_proper_url_no_slash(self): - r = self.client.get("/docs/pip") - self.assertEqual(r.status_code, 404) - - # Specific Page Redirects - - # If slug is neither valid lang nor valid version, it should 404. - # TODO: This should 404 directly, not redirect first - def test_improper_url_with_nonexistent_slug(self): - r = self.client.get("/docs/pip/nonexistent/") - self.assertEqual(r.status_code, 404) - - def test_improper_url_filename_only(self): - r = self.client.get("/docs/pip/test.html") - self.assertEqual(r.status_code, 404) - - def test_improper_url_dir_file(self): - r = self.client.get("/docs/pip/nonexistent_dir/bogus.html") - self.assertEqual(r.status_code, 404) - - def test_improper_url_dir_subdir_file(self): - r = self.client.get("/docs/pip/nonexistent_dir/subdir/bogus.html") - self.assertEqual(r.status_code, 404) - - def test_improper_url_lang_file(self): - r = self.client.get("/docs/pip/en/bogus.html") - self.assertEqual(r.status_code, 404) - - def test_improper_url_lang_subdir_file(self): - r = self.client.get("/docs/pip/en/nonexistent_dir/bogus.html") - self.assertEqual(r.status_code, 404) - - def test_improper_url_version_dir_file(self): - r = self.client.get("/docs/pip/latest/nonexistent_dir/bogus.html") - self.assertEqual(r.status_code, 404) - - # Specific Page Redirects - - @override_settings(USE_SUBDOMAIN=True) - def test_improper_subdomain_filename_only(self): - r = self.client.get("/test.html", headers={"host": "pip.readthedocs.org"}) - self.assertEqual(r.status_code, 404) - - -@override_settings(PUBLIC_DOMAIN="readthedocs.org", USE_SUBDOMAIN=False) -class RedirectAppTests(TestCase): - fixtures = ["eric", "test_data"] - - def setUp(self): - self.client.login(username="eric", password="test") - self.pip = Project.objects.get(slug="pip") - self.pip.versions.create_latest() - - class CustomRedirectTests(TestCase): @classmethod def setUpTestData(cls): @@ -102,11 +33,11 @@ def setUpTestData(cls): def test_redirect_fragment(self): redirect = Redirect.objects.get(project=self.pip) path = redirect.get_redirect_path("/install.html") - expected_path = "/docs/pip/en/latest/install.html#custom-fragment" + expected_path = "/en/latest/install.html#custom-fragment" self.assertEqual(path, expected_path) -@override_settings(PUBLIC_DOMAIN="readthedocs.org", USE_SUBDOMAIN=False) +@override_settings(PUBLIC_DOMAIN="readthedocs.org") class RedirectBuildTests(TestCase): fixtures = ["eric", "test_data"] @@ -131,7 +62,7 @@ def test_redirect_detail(self): self.assertEqual(r["Location"], "/projects/project-1/builds/1337/") -@override_settings(PUBLIC_DOMAIN="readthedocs.org", USE_SUBDOMAIN=False) +@override_settings(PUBLIC_DOMAIN="readthedocs.org") class GetFullPathTests(TestCase): fixtures = ["eric", "test_data"] @@ -143,7 +74,7 @@ def test_http_filenames_return_themselves(self): # If the crossdomain flag is False (default), then we don't redirect to a different host self.assertEqual( self.redirect.get_full_path("http://rtfd.org"), - "/docs/read-the-docs/en/latest/http://rtfd.org", + "/en/latest/http://rtfd.org", ) self.assertEqual( @@ -154,11 +85,10 @@ def test_http_filenames_return_themselves(self): def test_redirects_no_subdomain(self): self.assertEqual( self.redirect.get_full_path("index.html"), - "/docs/read-the-docs/en/latest/index.html", + "/en/latest/index.html", ) @override_settings( - USE_SUBDOMAIN=True, PRODUCTION_DOMAIN="rtfd.org", ) def test_redirects_with_subdomain(self): @@ -168,7 +98,6 @@ def test_redirects_with_subdomain(self): ) @override_settings( - USE_SUBDOMAIN=True, PRODUCTION_DOMAIN="rtfd.org", ) def test_single_version_with_subdomain(self): @@ -182,5 +111,5 @@ def test_single_version_no_subdomain(self): self.redirect.project.single_version = True self.assertEqual( self.redirect.get_full_path("faq.html"), - "/docs/read-the-docs/faq.html", + "/faq.html", ) diff --git a/readthedocs/rtd_tests/tests/test_resolver.py b/readthedocs/rtd_tests/tests/test_resolver.py index adc5714733f..4ff8be50442 100644 --- a/readthedocs/rtd_tests/tests/test_resolver.py +++ b/readthedocs/rtd_tests/tests/test_resolver.py @@ -59,71 +59,55 @@ def setUp(self): class SmartResolverPathTests(ResolverBase): def test_resolver_filename(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="/foo/bar/blah.html") - self.assertEqual(url, "/docs/pip/en/latest/foo/bar/blah.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.pip, filename="/foo/bar/blah.html") - self.assertEqual(url, "/en/latest/foo/bar/blah.html") - - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="") - self.assertEqual(url, "/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.pip, filename="") - self.assertEqual(url, "/en/latest/") + url = resolve_path(project=self.pip, filename="/foo/bar/blah.html") + self.assertEqual(url, "/en/latest/foo/bar/blah.html") + + url = resolve_path(project=self.pip, filename="") + self.assertEqual(url, "/en/latest/") def test_resolver_filename_index(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="foo/bar/index.html") - self.assertEqual(url, "/docs/pip/en/latest/foo/bar/index.html") - url = resolve_path( - project=self.pip, - filename="foo/index/index.html", - ) - self.assertEqual(url, "/docs/pip/en/latest/foo/index/index.html") + url = resolve_path(project=self.pip, filename="foo/bar/index.html") + self.assertEqual(url, "/en/latest/foo/bar/index.html") + url = resolve_path( + project=self.pip, + filename="foo/index/index.html", + ) + self.assertEqual(url, "/en/latest/foo/index/index.html") def test_resolver_filename_false_index(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="foo/foo_index.html") - self.assertEqual(url, "/docs/pip/en/latest/foo/foo_index.html") - url = resolve_path( - project=self.pip, - filename="foo_index/foo_index.html", - ) - self.assertEqual( - url, - "/docs/pip/en/latest/foo_index/foo_index.html", - ) + url = resolve_path(project=self.pip, filename="foo/foo_index.html") + self.assertEqual(url, "/en/latest/foo/foo_index.html") + url = resolve_path( + project=self.pip, + filename="foo_index/foo_index.html", + ) + self.assertEqual( + url, + "/en/latest/foo_index/foo_index.html", + ) def test_resolver_filename_sphinx(self): self.pip.documentation_type = "sphinx" - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="foo/bar") - self.assertEqual(url, "/docs/pip/en/latest/foo/bar") + url = resolve_path(project=self.pip, filename="foo/bar") + self.assertEqual(url, "/en/latest/foo/bar") - url = resolve_path(project=self.pip, filename="foo/index") - self.assertEqual(url, "/docs/pip/en/latest/foo/index") + url = resolve_path(project=self.pip, filename="foo/index") + self.assertEqual(url, "/en/latest/foo/index") def test_resolver_filename_mkdocs(self): self.pip.documentation_type = "mkdocs" - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="foo/bar") - self.assertEqual(url, "/docs/pip/en/latest/foo/bar") + url = resolve_path(project=self.pip, filename="foo/bar") + self.assertEqual(url, "/en/latest/foo/bar") - url = resolve_path(project=self.pip, filename="foo/index.html") - self.assertEqual(url, "/docs/pip/en/latest/foo/index.html") + url = resolve_path(project=self.pip, filename="foo/index.html") + self.assertEqual(url, "/en/latest/foo/index.html") - url = resolve_path(project=self.pip, filename="foo/bar.html") - self.assertEqual(url, "/docs/pip/en/latest/foo/bar.html") + url = resolve_path(project=self.pip, filename="foo/bar.html") + self.assertEqual(url, "/en/latest/foo/bar.html") def test_resolver_subdomain(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="index.html") - self.assertEqual(url, "/docs/pip/en/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.pip, filename="index.html") - self.assertEqual(url, "/en/latest/index.html") + url = resolve_path(project=self.pip, filename="index.html") + self.assertEqual(url, "/en/latest/index.html") def test_resolver_domain_object(self): self.domain = fixture.get( @@ -133,12 +117,8 @@ def test_resolver_domain_object(self): canonical=True, https=False, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="index.html") - self.assertEqual(url, "/en/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.pip, filename="index.html") - self.assertEqual(url, "/en/latest/index.html") + url = resolve_path(project=self.pip, filename="index.html") + self.assertEqual(url, "/en/latest/index.html") def test_resolver_domain_object_not_canonical(self): self.domain = fixture.get( @@ -148,47 +128,27 @@ def test_resolver_domain_object_not_canonical(self): canonical=False, https=False, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.pip, filename="") - self.assertEqual(url, "/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.pip, filename="") - self.assertEqual(url, "/en/latest/") + url = resolve_path(project=self.pip, filename="") + self.assertEqual(url, "/en/latest/") def test_resolver_subproject_subdomain(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/docs/pip/projects/sub/ja/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/projects/sub/ja/latest/index.html") + url = resolve_path(project=self.subproject, filename="index.html") + self.assertEqual(url, "/projects/sub/ja/latest/index.html") def test_resolver_subproject_single_version(self): self.subproject.single_version = True - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/docs/pip/projects/sub/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/projects/sub/index.html") + url = resolve_path(project=self.subproject, filename="index.html") + self.assertEqual(url, "/projects/sub/index.html") def test_resolver_subproject_both_single_version(self): self.pip.single_version = True self.subproject.single_version = True - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/docs/pip/projects/sub/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.subproject, filename="index.html") - self.assertEqual(url, "/projects/sub/index.html") + url = resolve_path(project=self.subproject, filename="index.html") + self.assertEqual(url, "/projects/sub/index.html") def test_resolver_translation(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path(project=self.translation, filename="index.html") - self.assertEqual(url, "/docs/pip/ja/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path(project=self.translation, filename="index.html") - self.assertEqual(url, "/ja/latest/index.html") + url = resolve_path(project=self.translation, filename="index.html") + self.assertEqual(url, "/ja/latest/index.html") class ResolverPathOverrideTests(ResolverBase): @@ -197,105 +157,37 @@ class ResolverPathOverrideTests(ResolverBase): def test_resolver_force_single_version(self): self.pip.single_version = False - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - single_version=True, - ) - self.assertEqual(url, "/docs/pip/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - single_version=True, - ) - self.assertEqual(url, "/index.html") - - def test_resolver_force_domain(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - cname=True, - ) - self.assertEqual(url, "/en/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - cname=True, - ) - self.assertEqual(url, "/en/latest/index.html") - - def test_resolver_force_domain_single_version(self): - self.pip.single_version = False - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - single_version=True, - cname=True, - ) - self.assertEqual(url, "/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - single_version=True, - cname=True, - ) - self.assertEqual(url, "/index.html") + url = resolve_path( + project=self.pip, + filename="index.html", + single_version=True, + ) + self.assertEqual(url, "/index.html") def test_resolver_force_language(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - language="cz", - ) - self.assertEqual(url, "/docs/pip/cz/latest/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - language="cz", - ) - self.assertEqual(url, "/cz/latest/index.html") + url = resolve_path( + project=self.pip, + filename="index.html", + language="cz", + ) + self.assertEqual(url, "/cz/latest/index.html") def test_resolver_force_version(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - version_slug="foo", - ) - self.assertEqual(url, "/docs/pip/en/foo/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - version_slug="foo", - ) - self.assertEqual(url, "/en/foo/index.html") + url = resolve_path( + project=self.pip, + filename="index.html", + version_slug="foo", + ) + self.assertEqual(url, "/en/foo/index.html") def test_resolver_force_language_version(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_path( - project=self.pip, - filename="index.html", - language="cz", - version_slug="foo", - ) - self.assertEqual(url, "/docs/pip/cz/foo/index.html") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_path( - project=self.pip, - filename="index.html", - language="cz", - version_slug="foo", - ) - self.assertEqual(url, "/cz/foo/index.html") + url = resolve_path( + project=self.pip, + filename="index.html", + language="cz", + version_slug="foo", + ) + self.assertEqual(url, "/cz/foo/index.html") class ResolverCanonicalProject(TestCase): @@ -382,12 +274,8 @@ def test_project_with_same_grandchild_project(self): class ResolverDomainTests(ResolverBase): @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_domain_resolver(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "pip.readthedocs.org") + url = resolve_domain(project=self.pip) + self.assertEqual(url, "pip.readthedocs.org") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", @@ -401,30 +289,22 @@ def test_domain_resolver_with_domain_object(self): canonical=True, https=False, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "docs.foobar.com") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "docs.foobar.com") + url = resolve_domain(project=self.pip) + self.assertEqual(url, "docs.foobar.com") - url = resolve_domain(project=self.pip, use_canonical_domain=False) - self.assertEqual(url, "pip.readthedocs.io") + url = resolve_domain(project=self.pip, use_canonical_domain=False) + self.assertEqual(url, "pip.readthedocs.io") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", ) def test_domain_resolver_subproject(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.subproject) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.subproject) - self.assertEqual(url, "pip.readthedocs.io") + url = resolve_domain(project=self.subproject) + self.assertEqual(url, "pip.readthedocs.io") - url = resolve_domain(project=self.subproject, use_canonical_domain=False) - self.assertEqual(url, "pip.readthedocs.io") + url = resolve_domain(project=self.subproject, use_canonical_domain=False) + self.assertEqual(url, "pip.readthedocs.io") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_domain_resolver_subproject_itself(self): @@ -440,27 +320,19 @@ def test_domain_resolver_subproject_itself(self): # add the project as subproject of itself self.pip.add_subproject(self.pip) - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "pip.readthedocs.org") + url = resolve_domain(project=self.pip) + self.assertEqual(url, "pip.readthedocs.org") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", ) def test_domain_resolver_translation(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.translation) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.translation) - self.assertEqual(url, "pip.readthedocs.io") + url = resolve_domain(project=self.translation) + self.assertEqual(url, "pip.readthedocs.io") - url = resolve_domain(project=self.translation, use_canonical_domain=False) - self.assertEqual(url, "pip.readthedocs.io") + url = resolve_domain(project=self.translation, use_canonical_domain=False) + self.assertEqual(url, "pip.readthedocs.io") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_domain_resolver_translation_itself(self): @@ -476,34 +348,25 @@ def test_domain_resolver_translation_itself(self): # add the project as subproject of itself self.pip.translations.add(self.pip) - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.pip) - self.assertEqual(url, "pip.readthedocs.org") + url = resolve_domain(project=self.pip) + self.assertEqual(url, "pip.readthedocs.org") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="public.readthedocs.org", ) def test_domain_public(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve_domain(project=self.translation) - self.assertEqual(url, "readthedocs.org") - with override_settings(USE_SUBDOMAIN=True): - url = resolve_domain(project=self.translation) - self.assertEqual(url, "pip.public.readthedocs.org") + url = resolve_domain(project=self.translation) + self.assertEqual(url, "pip.public.readthedocs.org") - url = resolve_domain(project=self.translation, use_canonical_domain=False) - self.assertEqual(url, "pip.public.readthedocs.org") + url = resolve_domain(project=self.translation, use_canonical_domain=False) + self.assertEqual(url, "pip.public.readthedocs.org") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="public.readthedocs.org", RTD_EXTERNAL_VERSION_DOMAIN="dev.readthedocs.build", PUBLIC_DOMAIN_USES_HTTPS=True, - USE_SUBDOMAIN=True, ) def test_domain_external(self): latest = self.pip.versions.first() @@ -520,12 +383,8 @@ def test_domain_external(self): class ResolverTests(ResolverBase): @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_domain(self): @@ -536,12 +395,8 @@ def test_resolver_domain(self): canonical=True, https=False, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://docs.foobar.com/en/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_domain_https(self): @@ -552,36 +407,21 @@ def test_resolver_domain_https(self): https=True, canonical=True, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "https://docs.foobar.com/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "https://docs.foobar.com/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "https://docs.foobar.com/en/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_subproject(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.subproject) - self.assertEqual( - url, - "http://readthedocs.org/docs/pip/projects/sub/ja/latest/", - ) - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.subproject) - self.assertEqual( - url, - "http://pip.readthedocs.org/projects/sub/ja/latest/", - ) + url = resolve(project=self.subproject) + self.assertEqual( + url, + "http://pip.readthedocs.org/projects/sub/ja/latest/", + ) @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_translation(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.translation) - self.assertEqual(url, "http://readthedocs.org/docs/pip/ja/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.translation) - self.assertEqual(url, "http://pip.readthedocs.org/ja/latest/") + url = resolve(project=self.translation) + self.assertEqual(url, "http://pip.readthedocs.org/ja/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_nested_translation_of_a_subproject(self): @@ -594,18 +434,11 @@ def test_resolver_nested_translation_of_a_subproject(self): main_language_project=self.subproject, ) - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=translation) - self.assertEqual( - url, - "http://readthedocs.org/docs/pip/projects/sub/es/latest/", - ) - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=translation) - self.assertEqual( - url, - "http://pip.readthedocs.org/projects/sub/es/latest/", - ) + url = resolve(project=translation) + self.assertEqual( + url, + "http://pip.readthedocs.org/projects/sub/es/latest/", + ) @pytest.mark.xfail(reason="We do not support this for now", strict=True) @override_settings(PRODUCTION_DOMAIN="readthedocs.org") @@ -635,102 +468,69 @@ def test_resolver_nested_subproject_of_a_translation(self): ) translation.add_subproject(subproject) - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=subproject) - self.assertEqual( - url, "http://readthedocs.org/docs/docs-es/projects/api-es/es/latest/" - ) - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=subproject) - self.assertEqual( - url, "http://docs-es.readthedocs.org/projects/api-es/es/latest/" - ) + url = resolve(project=subproject) + self.assertEqual( + url, "http://docs-es.readthedocs.org/projects/api-es/es/latest/" + ) @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_single_version(self): self.pip.single_version = True - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_subproject_alias(self): relation = self.pip.subprojects.first() relation.alias = "sub_alias" relation.save() - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.subproject) - self.assertEqual( - url, - "http://pip.readthedocs.org/projects/sub_alias/ja/latest/", - ) + url = resolve(project=self.subproject) + self.assertEqual( + url, + "http://pip.readthedocs.org/projects/sub_alias/ja/latest/", + ) @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_private_project(self): self.pip.privacy_level = PRIVATE self.pip.save() - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_private_project_override(self): self.pip.privacy_level = PRIVATE self.pip.save() - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") @override_settings(PRODUCTION_DOMAIN="readthedocs.org") def test_resolver_private_version_override(self): latest = self.pip.versions.first() latest.privacy_level = PRIVATE latest.save() - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://pip.readthedocs.org/en/latest/") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="public.readthedocs.org", ) def test_resolver_public_domain_overrides(self): - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://readthedocs.org/docs/pip/en/latest/") - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual( - url, - "http://pip.public.readthedocs.org/en/latest/", - ) - url = resolve(project=self.pip) - self.assertEqual( - url, - "http://pip.public.readthedocs.org/en/latest/", - ) + url = resolve(project=self.pip) + self.assertEqual( + url, + "http://pip.public.readthedocs.org/en/latest/", + ) + url = resolve(project=self.pip) + self.assertEqual( + url, + "http://pip.public.readthedocs.org/en/latest/", + ) # Domain overrides PUBLIC_DOMAIN self.domain = fixture.get( @@ -740,21 +540,14 @@ def test_resolver_public_domain_overrides(self): canonical=True, https=False, ) - with override_settings(USE_SUBDOMAIN=True): - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") - with override_settings(USE_SUBDOMAIN=False): - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") - url = resolve(project=self.pip) - self.assertEqual(url, "http://docs.foobar.com/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://docs.foobar.com/en/latest/") + url = resolve(project=self.pip) + self.assertEqual(url, "http://docs.foobar.com/en/latest/") @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_resolver_domain_https(self): with override_settings(PUBLIC_DOMAIN_USES_HTTPS=True): @@ -818,7 +611,7 @@ class ResolverTestsAlt(ResolverAltSetUp, ResolverTests): pass -@override_settings(USE_SUBDOMAIN=True, PUBLIC_DOMAIN="readthedocs.io") +@override_settings(PUBLIC_DOMAIN="readthedocs.io") class TestSubprojectsWithTranslations(TestCase): def setUp(self): self.subproject_en = fixture.get( @@ -932,7 +725,6 @@ def test_subproject_with_translation_with_custom_domain(self): @override_settings( - USE_SUBDOMAIN=True, PUBLIC_DOMAIN="readthedocs.io", RTD_EXTERNAL_VERSION_DOMAIN="readthedocs.build", ) diff --git a/readthedocs/rtd_tests/tests/test_single_version.py b/readthedocs/rtd_tests/tests/test_single_version.py index dfcfc06260c..a33e946e59d 100644 --- a/readthedocs/rtd_tests/tests/test_single_version.py +++ b/readthedocs/rtd_tests/tests/test_single_version.py @@ -6,7 +6,6 @@ @override_settings( - USE_SUBDOMAIN=True, PUBLIC_DOMAIN="public.readthedocs.org", SERVE_PUBLIC_DOCS=True, ) @@ -17,25 +16,13 @@ def setUp(self): ) def test_docs_url_generation(self): - with override_settings(USE_SUBDOMAIN=False): - self.assertEqual( - self.pip.get_docs_url(), - "http://readthedocs.org/docs/pip/", - ) - with override_settings(USE_SUBDOMAIN=True): - self.assertEqual( - self.pip.get_docs_url(), - "http://pip.public.readthedocs.org/", - ) + self.assertEqual( + self.pip.get_docs_url(), + "http://pip.public.readthedocs.org/", + ) self.pip.single_version = False - with override_settings(USE_SUBDOMAIN=False): - self.assertEqual( - self.pip.get_docs_url(), - "http://readthedocs.org/docs/pip/en/latest/", - ) - with override_settings(USE_SUBDOMAIN=True): - self.assertEqual( - self.pip.get_docs_url(), - "http://pip.public.readthedocs.org/en/latest/", - ) + self.assertEqual( + self.pip.get_docs_url(), + "http://pip.public.readthedocs.org/en/latest/", + ) diff --git a/readthedocs/rtd_tests/tests/test_version.py b/readthedocs/rtd_tests/tests/test_version.py index 65398c3c57b..8b3f1dab096 100644 --- a/readthedocs/rtd_tests/tests/test_version.py +++ b/readthedocs/rtd_tests/tests/test_version.py @@ -92,7 +92,6 @@ def test_commit_name_for_external_version(self): @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_get_downloads(self): version = self.branch_version @@ -110,7 +109,6 @@ def test_get_downloads(self): @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_get_downloads_subproject(self): version = self.subproject.versions.get(slug=LATEST) @@ -128,7 +126,6 @@ def test_get_downloads_subproject(self): @override_settings( PRODUCTION_DOMAIN="readthedocs.org", PUBLIC_DOMAIN="readthedocs.io", - USE_SUBDOMAIN=True, ) def test_get_downloads_translation_subproject(self): version = self.translation_subproject.versions.get(slug=LATEST) diff --git a/readthedocs/search/api/v3/tests/test_api.py b/readthedocs/search/api/v3/tests/test_api.py index 2550389743f..14b96f7a7c3 100644 --- a/readthedocs/search/api/v3/tests/test_api.py +++ b/readthedocs/search/api/v3/tests/test_api.py @@ -355,7 +355,7 @@ def test_search_subprojects(self): @pytest.mark.proxito -@override_settings(PUBLIC_DOMAIN="readthedocs.io", USE_SUBDOMAIN=True) +@override_settings(PUBLIC_DOMAIN="readthedocs.io") class ProxiedSearchAPITest(SearchAPITest): host = "project.readthedocs.io" diff --git a/readthedocs/search/tests/test_api.py b/readthedocs/search/tests/test_api.py index 3f4a868666f..454f56a2dea 100644 --- a/readthedocs/search/tests/test_api.py +++ b/readthedocs/search/tests/test_api.py @@ -36,7 +36,6 @@ def setup_method(self, method): @pytest.fixture(autouse=True) def setup_settings(self, settings): settings.PUBLIC_DOMAIN = "readthedocs.io" - settings.USE_SUBDOMAIN = True def get_search(self, api_client, search_params): return api_client.get(self.url, search_params) diff --git a/readthedocs/search/tests/test_views.py b/readthedocs/search/tests/test_views.py index 213467aaa19..8b7e6a9e062 100644 --- a/readthedocs/search/tests/test_views.py +++ b/readthedocs/search/tests/test_views.py @@ -264,7 +264,7 @@ def test_file_search_exact_match(self, client, project): assert results[1]["version"] == {"slug": "latest"} for result in results: assert result["project"] == {"alias": None, "slug": "kuma"} - assert result["domain"] == "http://readthedocs.org" + assert result["domain"] == "http://kuma.readthedocs.io" assert result["path"].endswith("/documentation.html") blocks = results[0]["blocks"] diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index 51082e05b7d..060ad837503 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -75,7 +75,6 @@ def SHOW_DEBUG_TOOLBAR(self): PRODUCTION_DOMAIN = 'readthedocs.org' PUBLIC_DOMAIN = None PUBLIC_DOMAIN_USES_HTTPS = False - USE_SUBDOMAIN = False PUBLIC_API_URL = 'https://{}'.format(PRODUCTION_DOMAIN) RTD_INTERSPHINX_URL = 'https://{}'.format(PRODUCTION_DOMAIN) RTD_EXTERNAL_VERSION_DOMAIN = 'external-builds.readthedocs.io' diff --git a/readthedocs/settings/docker_compose.py b/readthedocs/settings/docker_compose.py index 9ff216fac2f..abf8842449b 100644 --- a/readthedocs/settings/docker_compose.py +++ b/readthedocs/settings/docker_compose.py @@ -15,7 +15,6 @@ class DockerBaseSettings(CommunityBaseSettings): RTD_DOCKER_COMPOSE_VOLUME = "community_build-user-builds" RTD_DOCKER_USER = f"{os.geteuid()}:{os.getegid()}" DOCKER_LIMITS = {"memory": "1g", "time": 900} - USE_SUBDOMAIN = True PRODUCTION_DOMAIN = os.environ.get("RTD_PRODUCTION_DOMAIN", "devthedocs.org") PUBLIC_DOMAIN = os.environ.get("RTD_PUBLIC_DOMAIN", "devthedocs.org") diff --git a/readthedocs/settings/proxito/base.py b/readthedocs/settings/proxito/base.py index 8cf1e2b3d46..78f3badd3ef 100644 --- a/readthedocs/settings/proxito/base.py +++ b/readthedocs/settings/proxito/base.py @@ -12,7 +12,6 @@ class CommunityProxitoSettingsMixin: ROOT_URLCONF = "readthedocs.proxito.urls" - USE_SUBDOMAIN = True SECURE_REFERRER_POLICY = "no-referrer-when-downgrade" # Allow cookies from cross-site requests on subdomains for now. diff --git a/readthedocs/settings/test.py b/readthedocs/settings/test.py index 7278b0d6e70..8ba0544a7af 100644 --- a/readthedocs/settings/test.py +++ b/readthedocs/settings/test.py @@ -11,6 +11,7 @@ class CommunityTestSettings(CommunityBaseSettings): # A bunch of our tests check this value in a returned URL/Domain PRODUCTION_DOMAIN = "readthedocs.org" + PUBLIC_DOMAIN = "readthedocs.io" DONT_HIT_DB = False # Disable password validators on tests