def create_clean(self, file_obj): """ Shortcut to create a Signatory with a specific file. """ Signatory(name='test_signatory', title='Test Signatory', image=file_obj).full_clean()
def setUp(self): super(TestCertificates, self).setUp() self.site = Site.objects.create(domain='test', name='test') Signatory(name='test name', title='test title', image=SimpleUploadedFile('picture1.jpg', 'image contents!')).save() self.signatory = Signatory.objects.get(id=1)
def test_signatory_file_saving(self): """ Verify that asset file is saving with actual name and on correct path. """ Signatory(name='test name', title='Test Signatory', image=SimpleUploadedFile('image.jpg', 'file contents!')).save() signatory = Signatory.objects.get(id=1) self.assertEqual(signatory.image, 'signatories/1/image.jpg') # Now replace the asset with another file signatory.image = SimpleUploadedFile('image_2.jpg', 'file contents') signatory.save() signatory = Signatory.objects.get(id=1) self.assertEqual(signatory.image, 'signatories/1/image_2.jpg')
def test_good_image(self): """Verify that saving a valid signatory image is no problem.""" good_image = self.get_image('good') Signatory(name='test_signatory', title='Test Signatory', image=good_image).full_clean()