|
4 | 4 | from django.utils.six.moves.urllib.parse import urlsplit
|
5 | 5 |
|
6 | 6 | from readthedocs.builds.constants import LATEST
|
| 7 | +from readthedocs.projects.models import ImportedFile |
7 | 8 | from readthedocs.projects.models import Project
|
8 | 9 | from readthedocs.projects.forms import UpdateProjectForm
|
9 | 10 |
|
@@ -168,3 +169,37 @@ def test_project_redirects(self):
|
168 | 169 | def test_project_redirects_delete(self):
|
169 | 170 | response = self.client.get('/dashboard/pip/redirects/delete/')
|
170 | 171 | self.assertRedirectToLogin(response)
|
| 172 | + |
| 173 | + |
| 174 | +class RandomPageTests(TestCase): |
| 175 | + fixtures = ['eric', 'test_data'] |
| 176 | + |
| 177 | + def setUp(self): |
| 178 | + self.pip = Project.objects.get(slug='pip') |
| 179 | + self.pip_version = self.pip.versions.all()[0] |
| 180 | + ImportedFile.objects.create( |
| 181 | + project=self.pip, |
| 182 | + version=self.pip_version, |
| 183 | + name='File', |
| 184 | + slug='file', |
| 185 | + path='file.html', |
| 186 | + md5='abcdef', |
| 187 | + commit='1234567890abcdef') |
| 188 | + |
| 189 | + def test_random_page_view_redirects(self): |
| 190 | + response = self.client.get('/random/') |
| 191 | + self.assertEqual(response.status_code, 302) |
| 192 | + |
| 193 | + def test_takes_project_slug(self): |
| 194 | + response = self.client.get('/random/pip/') |
| 195 | + self.assertEqual(response.status_code, 302) |
| 196 | + self.assertTrue('/pip/' in response['Location']) |
| 197 | + |
| 198 | + def test_404_for_unknown_project(self): |
| 199 | + response = self.client.get('/random/not-existent/') |
| 200 | + self.assertEqual(response.status_code, 404) |
| 201 | + |
| 202 | + def test_404_for_with_no_imported_files(self): |
| 203 | + ImportedFile.objects.all().delete() |
| 204 | + response = self.client.get('/random/pip/') |
| 205 | + self.assertEqual(response.status_code, 404) |
0 commit comments