Пример #1
0
 def test_change_portrait_recatalogs(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     catalog = getToolByName(portal, 'portal_catalog')
     before = catalog.getCounter()
     mt.changeMemberPortrait(image_jpg)
     self.assertEqual(catalog.getCounter(), before + 1)
Пример #2
0
 def test_change_portrait_recatalogs(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     catalog = getToolByName(portal, 'portal_catalog')
     before = catalog.getCounter()
     mt.changeMemberPortrait(image_jpg)
     self.assertEqual(catalog.getCounter(), before + 1)
Пример #3
0
 def test_funky_ids(self):
     # Well, let's admit we really do this for the coverage.
     # There is this retarded check in changeMemberPortrait
     # that we copied and have to cover.
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mt.getPersonalPortrait(id='')
     path = os.path.join(TEST_IMAGES, 'test.gif')
     image_gif = make_file_upload(path, 'image/gif', 'myportrait.gif')
     mt.changeMemberPortrait(image_gif, id='')
Пример #4
0
    def test_change_portraits(self):
        portal = self.layer['portal']
        mt = getToolByName(portal, 'portal_membership')
        path = os.path.join(TEST_IMAGES, 'test.jpg')
        image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
        mt.changeMemberPortrait(image_jpg)
        portrait = mt.getPersonalPortrait(thumbnail=False)
        old_portrait_size = portrait.get_size()
        portrait = mt.getPersonalPortrait(thumbnail=True)
        old_thumbnail_size = portrait.get_size()

        # Now change the portraits
        path = os.path.join(TEST_IMAGES, 'test.gif')
        image_gif = make_file_upload(path, 'image/gif', 'myportrait.gif')
        mt.changeMemberPortrait(image_gif)
        portrait = mt.getPersonalPortrait(thumbnail=False)
        self.assertNotEqual(old_portrait_size, portrait.get_size())
        portrait = mt.getPersonalPortrait(thumbnail=True)
        self.assertNotEqual(old_thumbnail_size, portrait.get_size())
Пример #5
0
 def test_funky_ids(self):
     # Well, let's admit we really do this for the coverage.
     # There is this retarded check in changeMemberPortrait
     # that we copied and have to cover.
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mt.getPersonalPortrait(id='')
     path = os.path.join(TEST_IMAGES, 'test.gif')
     image_gif = make_file_upload(path, 'image/gif', 'myportrait.gif')
     mt.changeMemberPortrait(image_gif, id='')
Пример #6
0
    def test_change_portraits(self):
        portal = self.layer['portal']
        mt = getToolByName(portal, 'portal_membership')
        path = os.path.join(TEST_IMAGES, 'test.jpg')
        image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
        mt.changeMemberPortrait(image_jpg)
        portrait = mt.getPersonalPortrait(thumbnail=False)
        old_portrait_size = portrait.get_size()
        portrait = mt.getPersonalPortrait(thumbnail=True)
        old_thumbnail_size = portrait.get_size()

        # Now change the portraits
        path = os.path.join(TEST_IMAGES, 'test.gif')
        image_gif = make_file_upload(path, 'image/gif', 'myportrait.gif')
        mt.changeMemberPortrait(image_gif)
        portrait = mt.getPersonalPortrait(thumbnail=False)
        self.assertNotEqual(old_portrait_size, portrait.get_size())
        portrait = mt.getPersonalPortrait(thumbnail=True)
        self.assertNotEqual(old_thumbnail_size, portrait.get_size())
Пример #7
0
 def test_delete_portraits(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mdt = getToolByName(portal, 'portal_memberdata')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     mt.changeMemberPortrait(image_jpg)
     # Now delete the portraits
     mt.deletePersonalPortrait()
     self.failIf(TEST_USER_ID in mdt.portraits)
     self.failIf(TEST_USER_ID in mdt.thumbnails)
Пример #8
0
 def test_delete_portraits(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mdt = getToolByName(portal, 'portal_memberdata')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     mt.changeMemberPortrait(image_jpg)
     # Now delete the portraits
     mt.deletePersonalPortrait()
     self.failIf(TEST_USER_ID in mdt.portraits)
     self.failIf(TEST_USER_ID in mdt.thumbnails)
Пример #9
0
 def test_delete_member_purges_portrait(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mdt = getToolByName(portal, 'portal_memberdata')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     mt.changeMemberPortrait(image_jpg)
     # Now delete the member
     setRoles(portal, TEST_USER_ID, ['Manager'])
     mt.deleteMembers([TEST_USER_ID])
     self.failIf(TEST_USER_ID in mdt.portraits)
     self.failIf(TEST_USER_ID in mdt.thumbnails)
Пример #10
0
 def test_delete_member_purges_portrait(self):
     portal = self.layer['portal']
     mt = getToolByName(portal, 'portal_membership')
     mdt = getToolByName(portal, 'portal_memberdata')
     path = os.path.join(TEST_IMAGES, 'test.jpg')
     image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
     mt.changeMemberPortrait(image_jpg)
     # Now delete the member
     setRoles(portal, TEST_USER_ID, ['Manager'])
     mt.deleteMembers([TEST_USER_ID])
     self.failIf(TEST_USER_ID in mdt.portraits)
     self.failIf(TEST_USER_ID in mdt.thumbnails)
Пример #11
0
def add_default_members(portal):
    mtool = getToolByName(portal, 'portal_membership')
    default_member = mtool.getMemberById(TEST_USER_ID)
    default_member.setMemberProperties(
        dict(fullname='Memb\xc3\xa5r', email='*****@*****.**',
             position='Manager', department='Rock & Gravel'))
    default_member.changeMemberPortrait(
        make_file_upload(image_file, 'portrait.jpg', 'image/jpeg'))
    mtool.addMember('fred', 'secret', ['Member'], [],
        dict(fullname='Fred Flintstone', email='*****@*****.**',
             position='Crane Operator', department='Rock & Gravel'))
    mtool.addMember('barney', 'secret', ['Member'], [],
        dict(fullname='Barney Rubble', email='*****@*****.**',
             position='Head Accountant', department='Dept\xc3\xa5'))
Пример #12
0
    def test_set_portraits(self):
        portal = self.layer['portal']
        mt = getToolByName(portal, 'portal_membership')
        mdt = getToolByName(portal, 'portal_memberdata')
        path = os.path.join(TEST_IMAGES, 'test.jpg')
        image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
        mt.changeMemberPortrait(image_jpg)
        self.failUnless(TEST_USER_ID in mdt.portraits)
        self.failUnless(TEST_USER_ID in mdt.thumbnails)

        portrait_thumb = mt.getPersonalPortrait()
        from ..tools import PORTRAIT_SIZE, PORTRAIT_THUMBNAIL_SIZE
        self.assertEquals(portrait_thumb.width, PORTRAIT_THUMBNAIL_SIZE[0])
        self.assertEquals(portrait_thumb.height, PORTRAIT_THUMBNAIL_SIZE[1])
        portrait = mt.getPersonalPortrait(thumbnail=False)
        self.assertEquals(portrait.width, PORTRAIT_SIZE[0])
        self.assertEquals(portrait.height, PORTRAIT_SIZE[1])
Пример #13
0
    def test_set_portraits(self):
        portal = self.layer['portal']
        mt = getToolByName(portal, 'portal_membership')
        mdt = getToolByName(portal, 'portal_memberdata')
        path = os.path.join(TEST_IMAGES, 'test.jpg')
        image_jpg = make_file_upload(path, 'image/jpeg', 'myportrait.jpg')
        mt.changeMemberPortrait(image_jpg)
        self.failUnless(TEST_USER_ID in mdt.portraits)
        self.failUnless(TEST_USER_ID in mdt.thumbnails)

        portrait_thumb = mt.getPersonalPortrait()
        from ..tools import PORTRAIT_SIZE, PORTRAIT_THUMBNAIL_SIZE
        self.assertEquals(portrait_thumb.width, PORTRAIT_THUMBNAIL_SIZE[0])
        self.assertEquals(portrait_thumb.height, PORTRAIT_THUMBNAIL_SIZE[1])
        portrait = mt.getPersonalPortrait(thumbnail=False)
        self.assertEquals(portrait.width, PORTRAIT_SIZE[0])
        self.assertEquals(portrait.height, PORTRAIT_SIZE[1])
Пример #14
0
def add_default_members(portal):
    mtool = getToolByName(portal, 'portal_membership')
    default_member = mtool.getMemberById(TEST_USER_ID)
    default_member.setMemberProperties(
        dict(fullname='Memb\xc3\xa5r',
             email='*****@*****.**',
             position='Manager',
             department='Rock & Gravel'))
    default_member.changeMemberPortrait(
        make_file_upload(image_file, 'portrait.jpg', 'image/jpeg'))
    mtool.addMember(
        'fred', 'secret', ['Member'], [],
        dict(fullname='Fred Flintstone',
             email='*****@*****.**',
             position='Crane Operator',
             department='Rock & Gravel'))
    mtool.addMember(
        'barney', 'secret', ['Member'], [],
        dict(fullname='Barney Rubble',
             email='*****@*****.**',
             position='Head Accountant',
             department='Dept\xc3\xa5'))