def test_add(self):
video_file = create_test_video_file()
title = "Test Video"
response = self.post({
'title': title,
'file': SimpleUploadedFile('small.mp4', video_file.read(), "video/mp4"),
})
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailvideos:index'))
# Check that the video was created
videos = Video.objects.filter(title=title)
self.assertEqual(videos.count(), 1)
# Test that extra fields were populated from post_save signal
video = videos.first()
self.assertTrue(video.thumbnail)
self.assertTrue(video.duration)
self.assertTrue(video.file_size)
# Test that it was placed in the root collection
root_collection = Collection.get_first_root_node()
self.assertEqual(video.collection, root_collection)
评论列表
文章目录