Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_edit(self):
response = self.post({
'title': "Edited",
})
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailvideos:index'))
# Check that the video was edited
video = Video.objects.get(id=self.video.id)
self.assertEqual(video.title, "Edited")
self.assertEqual(self.video.file, video.file)
def test_add_too_long_filename(self):
video_file = create_test_video_file()
name = 'a_very_long_filename_' + ('x' * 100) + '.mp4'
response = self.post({
'title': "Test video",
'file': SimpleUploadedFile(name, video_file.read(), "video/mp4"),
})
# Should be valid
self.assertEqual(response.status_code, 302)
video = Video.objects.get()
self.assertEqual(len(video.file.name), Video._meta.get_field('file').max_length)
def test_edit_with_new_video_file(self):
# Change the file size of the video
self.video.file_size = 100000
self.video.save()
new_file = create_test_video_file()
response = self.post({
'title': "Edited",
'file': SimpleUploadedFile('new.mp4', new_file.read(), "video/mp4"),
})
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailvideos:index'))
# Check that the video file size changed (assume it changed to the correct value)
video = Video.objects.get(id=self.video.id)
self.assertNotEqual(video.file_size, 100000)