I'm trying to test a form for uploading a userimage, but i'm pretty
stuck with a custom filesystem that just doesn't seem to react to
overriding settings for testing. The filesystem is really simple and
looks like this:
social_user_fs =
FileSystemStorage(location=settings.SOCIAL_USER_FILES,
base_url=settings.SOCIAL_USER_URL)
In the models definition i then defined a function to return the url
for an image associated to that model:
def post_image(self):
try:
return self.image.url
except AttributeError:
return None
Now this works very well and behaves like i expect it to do. But i run
into a problem with testing:
class TestProfileImageUploadForm(TestCase):
# point the filesystem to the subfolder data of app/test/
@override_settings(SOCIAL_USER_FILES = os.path.dirname(__file__)+'/
data',
SOCIAL_USER_URL = 'profiles/')
def test_save(self):
profile = SocialUserProfile.objects.get(pk=1)
import ipdb; ipdb.set_trace()
Now the interactive debugging session gives me this:
ipdb> from django.conf import settings
ipdb> settings.SOCIAL_USER_FILES
'/Volumes/Data/Website/Backend/project/social_user/tests/data'
ipdb> settings.SOCIAL_USER_URL
'profiles/'
ipdb> profile.post_image()
'/user_files/profiles/1/profile_images/picture1-1.png'
# this is from the original settings
# the overridden settings should result in
# 'profiles/1/profile_images/picture1-1.png'
ipdb> f = file(profile.image.file)
*** IOError: [Errno 2] No such file or directory:
u'/Volumes/Data/Website/Backend/user_files/profiles/1/profile_images/
picture1-1.png'
# this is the path constructed from the original settings as well
So the settings have been overridden. It looks like my custom
filesystem is just not reacting to the override of the settings. Why
that? Any Ideas?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.