|
1 |
| -import re |
2 |
| - |
3 | 1 | from django.contrib.auth.models import User
|
4 | 2 | from django.contrib.messages import constants as message_const
|
| 3 | +from django_dynamic_fixture import get |
| 4 | +from django_dynamic_fixture import new |
| 5 | +from mock import patch |
5 | 6 |
|
6 | 7 | from readthedocs.rtd_tests.base import WizardTestCase, MockBuildTestCase
|
7 | 8 | from readthedocs.projects.models import Project
|
@@ -185,19 +186,38 @@ def test_import_demo_imported_duplicate(self):
|
185 | 186 |
|
186 | 187 |
|
187 | 188 | class TestPrivateViews(MockBuildTestCase):
|
188 |
| - fixtures = ['test_data', 'eric'] |
189 |
| - |
190 | 189 | def setUp(self):
|
| 190 | + self.user = new(User, username='eric') |
| 191 | + self.user.set_password('test') |
| 192 | + self.user.save() |
191 | 193 | self.client.login(username='eric', password='test')
|
192 | 194 |
|
193 | 195 | def test_versions_page(self):
|
| 196 | + pip = get(Project, slug='pip', users=[self.user]) |
| 197 | + pip.versions.create(verbose_name='1.0') |
| 198 | + |
194 | 199 | response = self.client.get('/projects/pip/versions/')
|
195 | 200 | self.assertEqual(response.status_code, 200)
|
196 | 201 |
|
197 | 202 | # Test if the versions page works with a version that contains a slash.
|
198 | 203 | # That broke in the past, see issue #1176.
|
199 |
| - pip = Project.objects.get(slug='pip') |
200 | 204 | pip.versions.create(verbose_name='1.0/with-slash')
|
201 | 205 |
|
202 | 206 | response = self.client.get('/projects/pip/versions/')
|
203 | 207 | self.assertEqual(response.status_code, 200)
|
| 208 | + |
| 209 | + def test_delete_project(self): |
| 210 | + project = get(Project, slug='pip', users=[self.user]) |
| 211 | + |
| 212 | + response = self.client.get('/dashboard/pip/delete/') |
| 213 | + self.assertEqual(response.status_code, 200) |
| 214 | + |
| 215 | + patcher = patch( |
| 216 | + 'readthedocs.projects.views.private.remove_path_from_web') |
| 217 | + with patcher as remove_path_from_web: |
| 218 | + response = self.client.post('/dashboard/pip/delete/') |
| 219 | + self.assertEqual(response.status_code, 302) |
| 220 | + |
| 221 | + self.assertFalse(Project.objects.filter(slug='pip').exists()) |
| 222 | + remove_path_from_web.delay.assert_called_with( |
| 223 | + path=project.doc_path) |
0 commit comments