def test_good_data(self):
"""Upload a zip with a single file it it: 'sample.jpg'.
It gets assigned to a newly created gallery 'Test'."""
test_data = copy.copy(self.sample_form_data)
response = self.client.post('/admin/photologue/photo/upload_zip/', test_data)
# The redirect Location has changed in Django 1.9 - it used to be an absolute URI, now it returns
# a relative one.
if VERSION[0] == 1 and VERSION[1] <= 8:
location = 'http://testserver/admin/photologue/photo/'
else:
location = '..'
self.assertEqual(response['Location'], location)
self.assertQuerysetEqual(Gallery.objects.all(),
['<Gallery: This is a test title>'])
self.assertQuerysetEqual(Photo.objects.all(),
['<Photo: This is a test title 1>'])
# The photo is attached to the gallery.
gallery = Gallery.objects.get(title='This is a test title')
self.assertQuerysetEqual(gallery.photos.all(),
['<Photo: This is a test title 1>'])
评论列表
文章目录