|
@@ -87,7 +87,7 @@ class BasicFormTests(TestCase):
|
|
|
|
|
|
def test_post_data(self):
|
|
|
res = self.client.post('/contact/', {'name': "Me", 'message': "Hello"})
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
|
|
|
|
|
|
class ModelFormMixinTests(TestCase):
|
|
@@ -117,7 +117,7 @@ class CreateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/authors/create/',
|
|
|
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
|
|
|
|
|
|
def test_create_invalid(self):
|
|
@@ -133,14 +133,14 @@ class CreateViewTests(TestCase):
|
|
|
{'name': 'Rene Magritte'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
artist = Artist.objects.get(name='Rene Magritte')
|
|
|
- self.assertRedirects(res, 'http://testserver/detail/artist/%d/' % artist.pk)
|
|
|
+ self.assertRedirects(res, '/detail/artist/%d/' % artist.pk)
|
|
|
self.assertQuerysetEqual(Artist.objects.all(), ['<Artist: Rene Magritte>'])
|
|
|
|
|
|
def test_create_with_redirect(self):
|
|
|
res = self.client.post('/edit/authors/create/redirect/',
|
|
|
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/authors/create/')
|
|
|
+ self.assertRedirects(res, '/edit/authors/create/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
|
|
|
|
|
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
|
@@ -152,7 +152,7 @@ class CreateViewTests(TestCase):
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe>'])
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
pk = Author.objects.first().pk
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
|
|
|
+ self.assertRedirects(res, '/edit/author/%d/update/' % pk)
|
|
|
# Also test with escaped chars in URL
|
|
|
res = self.client.post(
|
|
|
'/edit/authors/create/interpolate_redirect_nonascii/',
|
|
@@ -160,7 +160,7 @@ class CreateViewTests(TestCase):
|
|
|
)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
pk = Author.objects.get(name='John Doe').pk
|
|
|
- self.assertRedirects(res, 'http://testserver/%C3%A9dit/author/{}/update/'.format(pk))
|
|
|
+ self.assertRedirects(res, '/%C3%A9dit/author/{}/update/'.format(pk))
|
|
|
|
|
|
def test_create_with_special_properties(self):
|
|
|
res = self.client.get('/edit/authors/create/special/')
|
|
@@ -189,7 +189,7 @@ class CreateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/authors/create/restricted/',
|
|
|
{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/accounts/login/?next=/edit/authors/create/restricted/')
|
|
|
+ self.assertRedirects(res, '/accounts/login/?next=/edit/authors/create/restricted/')
|
|
|
|
|
|
def test_create_view_with_restricted_fields(self):
|
|
|
|
|
@@ -249,7 +249,7 @@ class UpdateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/author/%d/update/' % a.pk,
|
|
|
{'name': 'Randall Munroe (xkcd)', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (xkcd)>'])
|
|
|
|
|
|
def test_update_invalid(self):
|
|
@@ -269,7 +269,7 @@ class UpdateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/artists/%d/update/' % a.pk,
|
|
|
{'name': 'Rene Magritte'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/detail/artist/%d/' % a.pk)
|
|
|
+ self.assertRedirects(res, '/detail/artist/%d/' % a.pk)
|
|
|
self.assertQuerysetEqual(Artist.objects.all(), ['<Artist: Rene Magritte>'])
|
|
|
|
|
|
def test_update_with_redirect(self):
|
|
@@ -280,7 +280,7 @@ class UpdateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/author/%d/update/redirect/' % a.pk,
|
|
|
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/authors/create/')
|
|
|
+ self.assertRedirects(res, '/edit/authors/create/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
|
|
|
|
|
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
|
@@ -296,7 +296,7 @@ class UpdateViewTests(TestCase):
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
pk = Author.objects.first().pk
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/author/%d/update/' % pk)
|
|
|
+ self.assertRedirects(res, '/edit/author/%d/update/' % pk)
|
|
|
# Also test with escaped chars in URL
|
|
|
res = self.client.post(
|
|
|
'/edit/author/%d/update/interpolate_redirect_nonascii/' % a.pk,
|
|
@@ -304,7 +304,7 @@ class UpdateViewTests(TestCase):
|
|
|
)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
pk = Author.objects.get(name='John Doe').pk
|
|
|
- self.assertRedirects(res, 'http://testserver/%C3%A9dit/author/{}/update/'.format(pk))
|
|
|
+ self.assertRedirects(res, '/%C3%A9dit/author/{}/update/'.format(pk))
|
|
|
|
|
|
def test_update_with_special_properties(self):
|
|
|
a = Author.objects.create(
|
|
@@ -322,7 +322,7 @@ class UpdateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/author/%d/update/special/' % a.pk,
|
|
|
{'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/detail/author/%d/' % a.pk)
|
|
|
+ self.assertRedirects(res, '/detail/author/%d/' % a.pk)
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
|
|
|
|
|
|
def test_update_without_redirect(self):
|
|
@@ -354,7 +354,7 @@ class UpdateViewTests(TestCase):
|
|
|
res = self.client.post('/edit/author/update/',
|
|
|
{'name': 'Randall Munroe (xkcd)', 'slug': 'randall-munroe'})
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (xkcd)>'])
|
|
|
|
|
|
|
|
@@ -372,7 +372,7 @@ class DeleteViewTests(TestCase):
|
|
|
# Deletion with POST
|
|
|
res = self.client.post('/edit/author/%d/delete/' % a.pk)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), [])
|
|
|
|
|
|
def test_delete_by_delete(self):
|
|
@@ -380,14 +380,14 @@ class DeleteViewTests(TestCase):
|
|
|
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
res = self.client.delete('/edit/author/%d/delete/' % a.pk)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), [])
|
|
|
|
|
|
def test_delete_with_redirect(self):
|
|
|
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
res = self.client.post('/edit/author/%d/delete/redirect/' % a.pk)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/authors/create/')
|
|
|
+ self.assertRedirects(res, '/edit/authors/create/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), [])
|
|
|
|
|
|
@ignore_warnings(category=RemovedInDjango20Warning)
|
|
@@ -395,13 +395,13 @@ class DeleteViewTests(TestCase):
|
|
|
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
res = self.client.post('/edit/author/%d/delete/interpolate_redirect/' % a.pk)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/edit/authors/create/?deleted=%d' % a.pk)
|
|
|
+ self.assertRedirects(res, '/edit/authors/create/?deleted=%d' % a.pk)
|
|
|
self.assertQuerysetEqual(Author.objects.all(), [])
|
|
|
# Also test with escaped chars in URL
|
|
|
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
|
res = self.client.post('/edit/author/{}/delete/interpolate_redirect_nonascii/'.format(a.pk))
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/%C3%A9dit/authors/create/?deleted={}'.format(a.pk))
|
|
|
+ self.assertRedirects(res, '/%C3%A9dit/authors/create/?deleted={}'.format(a.pk))
|
|
|
|
|
|
def test_delete_with_special_properties(self):
|
|
|
a = Author.objects.create(**{'name': 'Randall Munroe', 'slug': 'randall-munroe'})
|
|
@@ -414,7 +414,7 @@ class DeleteViewTests(TestCase):
|
|
|
|
|
|
res = self.client.post('/edit/author/%d/delete/special/' % a.pk)
|
|
|
self.assertEqual(res.status_code, 302)
|
|
|
- self.assertRedirects(res, 'http://testserver/list/authors/')
|
|
|
+ self.assertRedirects(res, '/list/authors/')
|
|
|
self.assertQuerysetEqual(Author.objects.all(), [])
|
|
|
|
|
|
def test_delete_without_redirect(self):
|