mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-02 20:44:53 +00:00
Fixes to tests
This commit is contained in:
parent
f2a042da66
commit
ba886ce830
1 changed files with 16 additions and 18 deletions
|
|
@ -526,7 +526,6 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
|
||||
# Check response
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertEqual(response.content, "Cannot POST to this view without AJAX")
|
||||
|
||||
def test_add_post_nofile(self):
|
||||
"""
|
||||
|
|
@ -536,7 +535,6 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
|
||||
# Check response
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertEqual(response.content, "Must upload a file")
|
||||
|
||||
def test_edit_get(self):
|
||||
"""
|
||||
|
|
@ -554,35 +552,35 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
"""
|
||||
# Send request
|
||||
response = self.client.post(reverse('wagtailimages_edit_multiple', args=(self.image.id, )), {
|
||||
'title': "New title!",
|
||||
'tags': "",
|
||||
('image-%d-title' % self.image.id): "New title!",
|
||||
('image-%d-tags' % self.image.id): "",
|
||||
}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
|
||||
# Check response
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response['Content-Type'], 'application/json')
|
||||
|
||||
# Check JSON
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertIn('image_id', response_json)
|
||||
self.assertNotIn('form', response_json)
|
||||
self.assertIn('success', response_json)
|
||||
self.assertEqual(response_json['image_id'], self.image.id)
|
||||
self.assertTrue(response_json['success'])
|
||||
|
||||
def test_edit_post_noajax(self):
|
||||
"""
|
||||
This tests that a POST request to the edit view without AJAX returns a 400 response
|
||||
"""
|
||||
# Send request
|
||||
response = self.client.post(reverse('wagtailimages_edit_multiple', args=(self.image.id, )), {
|
||||
'title': "New title!",
|
||||
'tags': "",
|
||||
('image-%d-title' % self.image.id): "New title!",
|
||||
('image-%d-tags' % self.image.id): "",
|
||||
})
|
||||
|
||||
# Check response
|
||||
self.assertEqual(response.status_code, 400)
|
||||
|
||||
# Check JSON
|
||||
response_json = json.loads(response.content)
|
||||
self.assertIn('image_id', response_json)
|
||||
self.assertNotIn('form', response_json)
|
||||
self.assertIn('success', response_json)
|
||||
self.assertEqual(response_json['image_id'], self.image.id)
|
||||
self.assertTrue(response_json['success'])
|
||||
|
||||
def test_edit_post_validation_error(self):
|
||||
"""
|
||||
This tests that a POST request to the edit page returns a json document with "success=False"
|
||||
|
|
@ -590,8 +588,8 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
"""
|
||||
# Send request
|
||||
response = self.client.post(reverse('wagtailimages_edit_multiple', args=(self.image.id, )), {
|
||||
'title': "", # Required
|
||||
'tags': "",
|
||||
('image-%d-title' % self.image.id): "", # Required
|
||||
('image-%d-tags' % self.image.id): "",
|
||||
}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
|
||||
# Check response
|
||||
|
|
@ -603,7 +601,7 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
self.assertFormError(response, 'form', 'title', "This field is required.")
|
||||
|
||||
# Check JSON
|
||||
response_json = json.loads(response.content)
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertIn('image_id', response_json)
|
||||
self.assertIn('form', response_json)
|
||||
self.assertIn('success', response_json)
|
||||
|
|
@ -635,7 +633,7 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
self.assertFalse(Image.objects.filter(id=self.image.id).exists())
|
||||
|
||||
# Check JSON
|
||||
response_json = json.loads(response.content)
|
||||
response_json = json.loads(response.content.decode())
|
||||
self.assertIn('image_id', response_json)
|
||||
self.assertIn('success', response_json)
|
||||
self.assertEqual(response_json['image_id'], self.image.id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue