-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tests extensible from corporate site #4095
Changes from all commits
cd82565
8eaf66d
4623873
7ce8015
c58de84
be48ae2
ec133fb
d55a15e
9b06d61
f17e79e
e6c879d
02b3236
f98fb39
d4222e5
821f3c9
af4e010
10fd674
e10e2d4
7e96031
ab39aef
33813b5
7c2ec2e
638b740
86e2844
74c2094
7077050
7317ee9
178f4ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
import mock | ||
import pytest | ||
|
||
from django.conf import settings | ||
from django.test import TestCase | ||
from django.test.utils import override_settings | ||
|
||
|
@@ -9,11 +12,29 @@ | |
from readthedocs.core.templatetags import core_tags | ||
|
||
|
||
@override_settings(USE_SUBDOMAIN=False, PUBLIC_DOMAIN='readthedocs.org') | ||
@override_settings(USE_SUBDOMAIN=False, PRODUCTION_DOMAIN='readthedocs.org') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was wrong. The test wants to use It's using |
||
class CoreTagsTests(TestCase): | ||
fixtures = ["eric", "test_data"] | ||
|
||
def setUp(self): | ||
url_base = '{scheme}://{domain}/docs/pip{{version}}'.format( | ||
scheme=pytest.config.option.url_scheme, | ||
domain=settings.PRODUCTION_DOMAIN, | ||
) | ||
|
||
self.pip_latest_url = url_base.format(version='/en/latest/') | ||
self.pip_latest_fr_url = url_base.format(version='/fr/latest/') | ||
self.pip_abc_url = url_base.format(version='/en/abc/') | ||
self.pip_abc_fr_url = url_base.format(version='/fr/abc/') | ||
self.pip_abc_xyz_page_url = url_base.format(version='/en/abc/xyz.html') | ||
self.pip_abc_xyz_fr_page_url = url_base.format(version='/fr/abc/xyz.html') | ||
self.pip_abc_xyz_dir_url = url_base.format(version='/en/abc/xyz/') | ||
self.pip_abc_xyz_fr_dir_url = url_base.format(version='/fr/abc/xyz/') | ||
self.pip_abc_xyz_document = url_base.format(version='/en/abc/index.html#document-xyz') | ||
self.pip_abc_xyz_fr_document = url_base.format(version='/fr/abc/index.html#document-xyz') | ||
self.pip_latest_document_url = url_base.format(version='/en/latest/document/') | ||
self.pip_latest_document_page_url = url_base.format(version='/en/latest/document.html') | ||
|
||
with mock.patch('readthedocs.projects.models.broadcast'): | ||
self.client.login(username='eric', password='test') | ||
self.pip = Project.objects.get(slug='pip') | ||
|
@@ -22,164 +43,164 @@ def setUp(self): | |
def test_project_only(self): | ||
proj = Project.objects.get(slug='pip') | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
|
||
def test_project_only_htmldir(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
|
||
def test_project_only_singlehtml(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
|
||
def test_translation_project_only(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
|
||
def test_translation_project_only_htmldir(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
|
||
def test_translation_project_only_singlehtml(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj) | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
url = core_tags.make_document_url(proj, '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/latest/') | ||
self.assertEqual(url, self.pip_latest_fr_url) | ||
|
||
def test_project_and_version(self): | ||
proj = Project.objects.get(slug='pip') | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_project_and_version_htmldir(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_project_and_version_singlehtml(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_translation_project_and_version(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_translation_project_and_version_htmldir(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_translation_project_and_version_singlehtml(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj, 'abc') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
url = core_tags.make_document_url(proj, 'abc', '') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_project_and_version_and_page(self): | ||
proj = Project.objects.get(slug='pip') | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/xyz.html') | ||
self.assertEqual(url, self.pip_abc_xyz_page_url) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_project_and_version_and_page_htmldir(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/xyz/') | ||
self.assertEqual(url, self.pip_abc_xyz_dir_url) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_project_and_version_and_page_signlehtml(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/index.html#document-xyz') | ||
self.assertEqual(url, self.pip_abc_xyz_document) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/abc/') | ||
self.assertEqual(url, self.pip_abc_url) | ||
|
||
def test_translation_project_and_version_and_page(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/xyz.html') | ||
self.assertEqual(url, self.pip_abc_xyz_fr_page_url) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_translation_project_and_version_and_page_htmldir(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_htmldir' | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/xyz/') | ||
self.assertEqual(url, self.pip_abc_xyz_fr_dir_url) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_translation_project_and_version_and_page_singlehtml(self): | ||
proj = Project.objects.get(slug='pip-fr') | ||
proj.documentation_type = 'sphinx_singlehtml' | ||
url = core_tags.make_document_url(proj, 'abc', 'xyz') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/index.html#document-xyz') | ||
self.assertEqual(url, self.pip_abc_xyz_fr_document) | ||
url = core_tags.make_document_url(proj, 'abc', 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/fr/abc/') | ||
self.assertEqual(url, self.pip_abc_fr_url) | ||
|
||
def test_mkdocs(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'mkdocs' | ||
url = core_tags.make_document_url(proj, LATEST, 'document') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/document/') | ||
self.assertEqual(url, self.pip_latest_document_url) | ||
|
||
def test_mkdocs_no_directory_urls(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'mkdocs' | ||
url = core_tags.make_document_url(proj, LATEST, 'document.html') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/document.html') | ||
self.assertEqual(url, self.pip_latest_document_page_url) | ||
|
||
def test_mkdocs_index(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'mkdocs' | ||
url = core_tags.make_document_url(proj, LATEST, 'index') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
|
||
def test_mkdocs_index_no_directory_urls(self): | ||
proj = Project.objects.get(slug='pip') | ||
proj.documentation_type = 'mkdocs' | ||
url = core_tags.make_document_url(proj, LATEST, 'index.html') | ||
self.assertEqual(url, 'http://readthedocs.org/docs/pip/en/latest/') | ||
self.assertEqual(url, self.pip_latest_url) | ||
|
||
def test_restructured_text(self): | ||
value = '*test*' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import absolute_import | ||
import json | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conftest.py
is directory dependent. That's why we can't override these pytest's options here. I'd like to find a better way to do this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to define these
PYTEST_OPTIONS
in thesettings.py
file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this would be a good addition. Alternatively, maybe something in setup.cfg instead? I'm not sure if the load order would allow us to use django settings, given pytest-django likely sets up the application later in the process. We can make an issue to track updating this pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #4317 for this