def test_post(self):
# Build a fake file
fake_file = ContentFile(b("A boring example song"))
fake_file.name = 'song.mp3'
# Submit title change
post_data = {
'title': "Test media changed!",
'file': fake_file,
'duration': 100,
}
response = self.client.post(reverse('wagtailmedia:edit', args=(self.media.id,)), post_data)
# User should be redirected back to the index
self.assertRedirects(response, reverse('wagtailmedia:index'))
# Media title should be changed
self.assertEqual(models.Media.objects.get(id=self.media.id).title, "Test media changed!")
评论列表
文章目录