예제 #1
0
    def setUp(self):
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.portal.invokeFactory('Folder', 'test-folder')
        setRoles(self.portal, TEST_USER_ID, ['Member'])
        self.folder = self.portal['test-folder']

        self.folder.invokeFactory('File',
                                  id='v1',
                                  title='Video File',
                                  file=dummy.File(filename='test.mp4',
                                                  data=MP4))
        self.v1 = self.folder['v1']
        event = set_media_layout(self.v1, self.portal.REQUEST)
        notify(event)

        self.folder.invokeFactory('File',
                                  id='a1',
                                  title='Audio File',
                                  file=dummy.File(filename='test.mp3',
                                                  data=MP3))
        self.a1 = self.folder['a1']
        event = set_media_layout(self.a1, self.portal.REQUEST)
        notify(event)
    def test_get_commenter_portrait(self):

        # Add a user with a member image
        self.membershipTool.addMember('jim', 'Jim', ['Member'], [])
        self.memberdata._setPortrait(Image(
            id='jim',
            file=dummy.File(),
            title=''
        ), 'jim')
        self.assertEqual(
            self.memberdata._getPortrait('jim').getId(),
            'jim'
        )
        self.assertEqual(
            self.memberdata._getPortrait('jim').meta_type,
            'Image'
        )

        # Add a conversation with a comment
        conversation = IConversation(self.portal.doc1)
        comment = createObject('plone.Comment')
        comment.text = 'Comment text'
        comment.Creator = 'Jim'
        comment.author_username = '******'
        conversation.addComment(comment)

        # Call get_commenter_portrait method of the viewlet
        self.viewlet.update()
        portrait_url = self.viewlet.get_commenter_portrait('jim')

        # Check if the correct member image URL is returned
        self.assertEqual(
            portrait_url,
            'http://nohost/plone/portal_memberdata/portraits/jim'
        )
예제 #3
0
 def testUploadBadImage(self):
     # http://dev.plone.org/plone/ticket/3518
     try:
         self.folder[self.image_id].image_edit(file=dummy.File('fred%.gif'))
     except CopyError:
         # (ditto - see above)
         pass
     self.assertFalse('fred%.gif' in self.folder)
예제 #4
0
 def testUploadBadFile(self):
     # http://dev.plone.org/plone/ticket/3416
     try:
         self.folder[self.file_id].file_edit(file=dummy.File('fred%.txt'))
     except CopyError:
         # Somehow we'd get one of these *sometimes* (not consistently)
         # when running tests... since all we're testing is that the
         # object doesn't get renamed, this shouldn't matter
         pass
     self.assertFalse('fred%.txt' in self.folder)
예제 #5
0
 def testEditFormatMetadataOfFile(self):
     # Test fix for http://dev.plone.org/plone/ticket/1323
     self.folder.invokeFactory('File', id='file')
     self.folder.file.edit(file=dummy.File('foo.zip'))
     self.assertEqual(self.folder.file.Format(), 'application/zip')
     self.assertEqual(self.folder.file.getFile().content_type,
                      'application/zip')
     # Changing the format should be reflected in content_type property
     self.utils.editMetadata(self.folder.file, format='image/gif')
     self.assertEqual(self.folder.file.Format(), 'image/gif')
     self.assertEqual(self.folder.file.getFile().content_type, 'image/gif')
예제 #6
0
 def testFileEdit(self):
     self.folder.invokeFactory('File', id='file')
     self.folder.file.edit(file=dummy.File())
     self.assertEqual(str(self.folder.file), dummy.TEXT)
 def testFileCreate(self):
     self.folder.invokeFactory('File', id='file', file=dummy.File())
     self.assertEqual(str(self.folder.file), dummy.TEXT)
 def testFileCreate(self):
     self.folder.invokeFactory(
         'File', id='file', file=NamedFile(dummy.File()))
     self.assertEqual(self.folder.file.file.data, dummy.TEXT)
예제 #9
0
 def testUploadFile(self):
     self.folder[self.file_id].file_edit(file=dummy.File('fred.txt'))
     self.assertTrue('fred.txt' in self.folder)
예제 #10
0
 def afterSetUp(self):
     self.folder.invokeFactory('File', id='file')
     self.folder.file.file_edit(file=dummy.File('foo.pdf'))
     self.folder.invokeFactory('Image', id='image')
     self.folder.image.image_edit(file=dummy.Image('foo.gif'))
예제 #11
0
 def afterSetUp(self):
     self.folder.invokeFactory('File', id='file', file=dummy.File())
     self.folder.invokeFactory('Image', id='image', file=dummy.Image())
 def testUploadFile(self):
     self.folder[self.file_id].file_edit(file=dummy.File('fred.txt'))
     self.failUnless('fred.txt' in self.folder)