Esempio n. 1
0
 def test_clean_file_different_extension(self):
     instance = MagicMock()
     instance.file.name = 'foo.png'
     form = UploadedFileAdminForm(instance=instance)
     file_mock = MagicMock()
     file_mock.name = 'bar.pdf'
     form.cleaned_data = {'file': file_mock}
     assert_raises(ValidationError, form.clean_file)
Esempio n. 2
0
 def test_clean_file_different_extension(self):
     instance = MagicMock()
     instance.file.name = 'foo.png'
     form = UploadedFileAdminForm(instance=instance)
     file_mock = MagicMock()
     file_mock.name = 'bar.pdf'
     form.cleaned_data = {'file': file_mock}
     self.assertRaises(ValidationError, form.clean_file)
Esempio n. 3
0
 def test_clean_file(self):
     instance = MagicMock()
     instance.file.name = 'foo.png'
     form = UploadedFileAdminForm(instance=instance)
     file_mock = MagicMock()
     file_mock.name = 'bar.png'
     form.cleaned_data = {'file': file_mock}
     eq_(form.clean_file(), file_mock)
Esempio n. 4
0
 def test_clean_file(self):
     instance = MagicMock()
     instance.file.name = 'foo.png'
     form = UploadedFileAdminForm(instance=instance)
     file_mock = MagicMock()
     file_mock.name = 'bar.png'
     form.cleaned_data = {'file': file_mock}
     self.assertEqual(form.clean_file(), file_mock)