I try to mock FileUpload in django view (admin view).
My model looks like that:
class BaseImage(models.Model):
# create path for uploaded images
_storage_path = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'secure_media'))
_image_storage = FileSystemStorage(location=_storage_path)
image = SorlImageField(
verbose_name=_(u'image'),
storage=_image_storage,
upload_to="%Y/%m")
class Meta:
abstract = True
and test:
def test_add_new_as_main(self):
url = reverse('admin:galleries_secureimage_add')
post_data = {
'image': get_temporary_image()
}
response = self.client.post(url, post_data)
This uploads file to directory specified in _storage_path and I want to
change that in my test.
How can I mock _storage_path to return different path in my tests? I tried
to use Mock() library but can't make that work.
Can you help me?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8bcd2578-b9a9-4662-97ff-7867c88f2829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.