|
| 1 | +import mock |
| 2 | + |
1 | 3 | from django.test import TestCase
|
| 4 | +from django.test.utils import override_settings |
2 | 5 | from django.contrib.auth.models import User
|
3 | 6 |
|
4 | 7 | from readthedocs.projects.forms import SubprojectForm
|
5 | 8 | from readthedocs.projects.models import Project
|
| 9 | +from readthedocs.rtd_tests.utils import create_user |
6 | 10 |
|
7 | 11 | from django_dynamic_fixture import get
|
8 | 12 |
|
@@ -56,3 +60,33 @@ def test_admin_of_subproject_can_add_it(self):
|
56 | 60 | self.assertEqual(
|
57 | 61 | [r.child for r in project.subprojects.all()],
|
58 | 62 | [subproject])
|
| 63 | + |
| 64 | + |
| 65 | +@override_settings(PUBLIC_DOMAIN='readthedocs.org') |
| 66 | +class ResolverBase(TestCase): |
| 67 | + |
| 68 | + def setUp(self): |
| 69 | + with mock.patch('readthedocs.projects.models.broadcast'): |
| 70 | + with mock.patch('readthedocs.projects.models.update_static_metadata'): |
| 71 | + self.owner = create_user(username='owner', password='test') |
| 72 | + self.tester = create_user(username='tester', password='test') |
| 73 | + self.pip = get(Project, slug='pip', users=[self.owner], main_language_project=None) |
| 74 | + self.subproject = get(Project, slug='sub', language='ja', users=[ |
| 75 | + self.owner], main_language_project=None) |
| 76 | + self.translation = get(Project, slug='trans', language='ja', users=[ |
| 77 | + self.owner], main_language_project=None) |
| 78 | + self.pip.add_subproject(self.subproject) |
| 79 | + self.pip.translations.add(self.translation) |
| 80 | + |
| 81 | + @override_settings(PRODUCTION_DOMAIN='readthedocs.org') |
| 82 | + def test_resolver_subproject_alias(self): |
| 83 | + relation = self.pip.subprojects.first() |
| 84 | + relation.alias = 'sub_alias' |
| 85 | + relation.save() |
| 86 | + with override_settings(USE_SUBDOMAIN=False): |
| 87 | + resp = self.client.get('/docs/pip/projects/sub_alias/') |
| 88 | + self.assertEqual(resp.status_code, 302) |
| 89 | + self.assertEqual( |
| 90 | + resp._headers['location'][1], |
| 91 | + 'http://readthedocs.org/docs/pip/projects/sub_alias/ja/latest/' |
| 92 | + ) |
0 commit comments