def test_no_existing_photo(self): handle_photo_upload(self.context,None,self.cstruct) content = self.context['photo'] compare(content.title,'Photo of firstname lastname') compare(content.mimetype,'image/jpeg') compare(content.filename,'test.jpg') compare(content.creator,'auser')
def handle_content(self, context, request, validated): # Handle the easy ones names_fieldset = validated['names_fieldset'] context.firstname=names_fieldset['first_name'] context.lastname=names_fieldset['last_name'] context.email=names_fieldset['email'] context.position=validated['details']['position'] context.organization=validated['details']['organization'] context.biography=validated['details']['biography'] context.country=validated['details']['country'] # change password users = find_users(context) if validated['passwords']['password']: users = find_users(context) users.change_password(context.__name__,validated['passwords']['password']) # handle websites context.websites=[] for url in validated['details']['websites']: if not ( url.startswith('http://') or url.startswith('https://') ): url = 'http://'+url context.websites.append(url) # Handle the picture handle_photo_upload(context, request, validated['profile_image']['photo']) # Handle the social networking stuff socials = validated['details']['social_networks'] for name in ('facebook', 'twitter'): id = socials[name] if id: if name == 'twitter' and not id.startswith('@'): id = '@' + id item = self.social_category.get(name) if not item: item = SocialCategoryItem( id=id, title=name, description=u'' ) context.categories['social'][name] = item else: item.id = id
def test_no_cstruct(self): handle_photo_upload(self.context,None,None) self.assertFalse(self.context.get('photo'))