def test_add_with_collections(self):
root_collection = Collection.get_first_root_node()
evil_plans_collection = root_collection.add_child(name="Evil plans")
response = self.post({
'title': "Test video",
'file': SimpleUploadedFile('small.mp4', create_test_video_file().read(), "video/mp4"),
'collection': evil_plans_collection.id,
})
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailvideos:index'))
# Check that the video was created
videos = Video.objects.filter(title="Test video")
self.assertEqual(videos.count(), 1)
# Test that it was placed in the Evil Plans collection
video = videos.first()
self.assertEqual(video.collection, evil_plans_collection)
评论列表
文章目录