Skip to content

Commit 579f241

Browse files
authored
Merge pull request #6714 from stsewd/run-proxito-tests-with-proxito
Run proxito tests with proxito
2 parents 0e5b8ba + 7415eea commit 579f241

File tree

12 files changed

+42
-35
lines changed

12 files changed

+42
-35
lines changed

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ addopts = --reuse-db --strict-markers
33
markers =
44
search
55
serve
6+
proxito
67
python_files = tests.py test_*.py *_tests.py
78
filterwarnings =
89
# Ignore external dependencies warning deprecations

readthedocs/proxito/tests/base.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copied from .org
22

33

4+
import pytest
45
import django_dynamic_fixture as fixture
56
from django.contrib.auth.models import User
67
from django.test import TestCase
@@ -10,19 +11,7 @@
1011
from readthedocs.projects.models import Project
1112

1213

13-
@override_settings(
14-
PUBLIC_DOMAIN='dev.readthedocs.io',
15-
ROOT_URLCONF='readthedocs.proxito.urls',
16-
MIDDLEWARE=[
17-
# Auth middleware is required since some views uses ``request.user``
18-
'django.contrib.sessions.middleware.SessionMiddleware',
19-
'django.contrib.auth.middleware.AuthenticationMiddleware',
20-
21-
'readthedocs.proxito.middleware.ProxitoMiddleware',
22-
],
23-
USE_SUBDOMAIN=True,
24-
RTD_BUILD_MEDIA_STORAGE='readthedocs.rtd_tests.storage.BuildMediaFileSystemStorageTest',
25-
)
14+
@pytest.mark.proxito
2615
class BaseDocServing(TestCase):
2716

2817
def setUp(self):

readthedocs/proxito/tests/test_full.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def test_project_nginx_serving_unicode_filename(self):
213213
@override_settings(
214214
PYTHON_MEDIA=False,
215215
PUBLIC_DOMAIN='readthedocs.io',
216+
RTD_BUILD_MEDIA_STORAGE='readthedocs.rtd_tests.storage.BuildMediaFileSystemStorageTest',
216217
)
217218
class TestAdditionalDocViews(BaseDocServing):
218219
# Test that robots.txt and sitemap.xml work

readthedocs/proxito/tests/test_middleware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copied from test_middleware.py
22

3+
import pytest
34
from django.test import TestCase
45
from django.test.utils import override_settings
56
from django_dynamic_fixture import get
@@ -10,8 +11,8 @@
1011
from readthedocs.rtd_tests.utils import create_user
1112

1213

13-
@override_settings(USE_SUBDOMAIN=True)
1414
@override_settings(PUBLIC_DOMAIN='dev.readthedocs.io')
15+
@pytest.mark.proxito
1516
class MiddlewareTests(RequestFactoryTestMixin, TestCase):
1617

1718
def setUp(self):

readthedocs/proxito/tests/test_old_redirects.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import django_dynamic_fixture as fixture
1313
import pytest
1414
from django.http import Http404
15-
from django.urls import reverse
1615
from django.test.utils import override_settings
16+
from django.urls import reverse
1717

1818
from readthedocs.builds.models import Version
1919
from readthedocs.redirects.models import Redirect
@@ -22,9 +22,7 @@
2222
from .mixins import MockStorageMixin
2323

2424

25-
@override_settings(
26-
RTD_BUILD_MEDIA_STORAGE='readthedocs.proxito.tests.storage.BuildMediaStorageTest',
27-
)
25+
@override_settings(PUBLIC_DOMAIN='dev.readthedocs.io')
2826
class InternalRedirectTests(BaseDocServing):
2927

3028
"""
@@ -162,8 +160,8 @@ def test_root_redirect_with_query_params(self):
162160
# 404 directly and avoid using PYTHON_MEDIA.
163161
@override_settings(
164162
PYTHON_MEDIA=True,
163+
PUBLIC_DOMAIN='dev.readthedocs.io',
165164
ROOT_URLCONF='readthedocs.proxito.tests.handler_404_urls',
166-
RTD_BUILD_MEDIA_STORAGE='readthedocs.proxito.tests.storage.BuildMediaStorageTest',
167165
)
168166
class UserRedirectTests(MockStorageMixin, BaseDocServing):
169167

readthedocs/proxito/tests/test_proxied_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from readthedocs.rtd_tests.tests.test_footer import BaseTestFooterHTML
44

55

6-
@override_settings(
7-
PUBLIC_DOMAIN='readthedocs.io',
8-
ROOT_URLCONF='readthedocs.proxito.urls',
9-
)
6+
@override_settings(PUBLIC_DOMAIN='readthedocs.io')
107
class TestProxiedFooterHTML(BaseTestFooterHTML, TestCase):
118

129
def setUp(self):

readthedocs/proxito/tests/test_redirects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
from .base import BaseDocServing
77

88

9-
@override_settings(PUBLIC_DOMAIN_USES_HTTPS=True)
9+
@override_settings(
10+
PUBLIC_DOMAIN='dev.readthedocs.io',
11+
PUBLIC_DOMAIN_USES_HTTPS=True,
12+
)
1013
class RedirectTests(BaseDocServing):
1114

1215
def test_root_url(self):

readthedocs/proxito/tests/test_urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Copied from .com codebase
22

3-
# -*- coding: utf-8 -*-
43
"""Test URL config."""
54

6-
from django.urls import resolve
5+
import pytest
76
from django.test import TestCase, override_settings
7+
from django.urls import resolve
88

99

10-
@override_settings(ROOT_URLCONF='readthedocs.proxito.urls')
10+
@pytest.mark.proxito
1111
class TestSingleVersionURLs(TestCase):
1212

1313
def test_root(self):

readthedocs/search/tests/test_proxied_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
from readthedocs.search.tests.test_api import BaseTestDocumentSearch
44

55

6-
@pytest.mark.urls('readthedocs.proxito.urls')
6+
@pytest.mark.proxito
77
@pytest.mark.search
88
class TestProxiedSearchAPI(BaseTestDocumentSearch):
99

1010
host = 'pip.readthedocs.io'
1111

12+
@pytest.fixture(autouse=True)
13+
def setup_settings(self, settings):
14+
settings.PUBLIC_DOMAIN = 'readthedocs.io'
15+
1216
def get_search(self, api_client, search_params):
1317
return api_client.get(self.url, search_params, HTTP_HOST=self.host)

readthedocs/search/tests/test_views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
@pytest.mark.django_db
1717
@pytest.mark.search
1818
class TestProjectSearch:
19-
url = reverse('search')
19+
20+
@pytest.fixture(autouse=True)
21+
def setup(self):
22+
self.url = reverse('search')
2023

2124
def _get_search_result(self, url, client, search_params):
2225
resp = client.get(url, search_params)
@@ -84,7 +87,10 @@ def test_search_project_filter_language(self, client, project):
8487
@pytest.mark.django_db
8588
@pytest.mark.search
8689
class TestPageSearch:
87-
url = reverse('search')
90+
91+
@pytest.fixture(autouse=True)
92+
def setup(self):
93+
self.url = reverse('search')
8894

8995
def _get_search_result(self, url, client, search_params):
9096
resp = client.get(url, search_params)

readthedocs/settings/proxito/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from ..test import CommunityTestSettings
2-
from .base import ProxitoSettingsMixin
2+
from .base import CommunityProxitoSettingsMixin
33

44

55
class CommunityProxitoTestSettings(
6-
ProxitoSettingsMixin,
6+
CommunityProxitoSettingsMixin,
77
CommunityTestSettings
88
):
99

10-
pass
11-
10+
PUBLIC_DOMAIN = 'dev.readthedocs.io'
11+
RTD_BUILD_MEDIA_STORAGE = 'readthedocs.proxito.tests.storage.BuildMediaStorageTest'
1212

1313
CommunityProxitoTestSettings.load_settings(__name__)

tox.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ passenv = CI TRAVIS TRAVIS_*
1919
deps = -r{toxinidir}/requirements/testing.txt
2020
changedir = {toxinidir}/readthedocs
2121
commands =
22-
pytest --cov-report= --cov-config {toxinidir}/.coveragerc --cov=. --suppress-no-test-exit-code {posargs:{env:TOX_POSARGS:-m 'not search'}}
22+
/bin/sh -c '\
23+
export DJANGO_SETTINGS_MODULE=readthedocs.settings.test; \
24+
pytest --cov-report= --cov-config {toxinidir}/.coveragerc --cov=. --suppress-no-test-exit-code -m "not proxito" {posargs:{env:TOX_POSARGS:-m "not search and not proxito"}}'
25+
26+
/bin/sh -c '\
27+
export DJANGO_SETTINGS_MODULE=readthedocs.settings.proxito.test; \
28+
pytest --cov-report= --cov-config {toxinidir}/.coveragerc --cov=. --cov-append -m proxito --suppress-no-test-exit-code {posargs}'
29+
2330

2431
[testenv:docs]
2532
description = build readthedocs documentation

0 commit comments

Comments
 (0)