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 = Trueand 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?