def test_edit_no_changes(self): base64_picture_mime = b64.encodestring(PICTURE) obj = WebcamTestModel(photo=PictureUploadedFile(get_picture_name(), PICTURE)) obj.save() obj = WebcamTestModel.objects.get(pk=obj.pk) prev_name = obj.photo Form = modelform_factory(WebcamTestModel) form = Form({'data_photo': base64_picture_mime}, instance=obj) obj = form.save() self.assertTrue(os.path.isfile(temp_storage.path(obj.photo.name)), '`{0.photo.name}` is not a file'.format(obj)) self.assertEqual(prev_name, obj.photo)
def test_edit_no_changes(self): base64_picture_mime = b64.encodestring(PICTURE) obj = WebcamTestModel( photo=PictureUploadedFile(get_picture_name(), PICTURE)) obj.save() obj = WebcamTestModel.objects.get(pk=obj.pk) prev_name = obj.photo Form = modelform_factory(WebcamTestModel) form = Form({'data_photo': base64_picture_mime}, instance=obj) obj = form.save() self.assertTrue(os.path.isfile(temp_storage.path(obj.photo.name)), '`{0.photo.name}` is not a file'.format(obj)) self.assertEqual(prev_name, obj.photo)
def get_filename(self, filename): if not filename: filename = get_picture_name(self.format) return os.path.normpath(self.storage.get_valid_name(os.path.basename(filename)))