示例#1
0
    def afterSetUp(self):
        super(FunctionalTestCase, self).afterSetUp()
        self.loginAsPortalOwner()
        wtool = getToolByName(self.portal, 'portal_workflow')

        # Image file
        pkg_home = Common.package_home({'__name__': 'collective.imagetags'})
        samplesdir = os.path.join(pkg_home, 'tests', 'samples')
        image_file = file(os.path.join(samplesdir, 'test_image.png')).read()

        # News item without image
        id = self.portal.invokeFactory('News Item', 'no-image')
        ob = getattr(self.portal, id)
        ob.setTitle('News item without image')
        wtool.doActionFor(ob, 'publish')

        # News item with image
        id = self.portal.invokeFactory('News Item', 'with-image')
        ob = getattr(self.portal, id)
        ob.setTitle('News item with image')
        ob.setImage(image_file)
        wtool.doActionFor(ob, 'publish')

        # Image
        id = self.portal.invokeFactory('Image', 'image')
        ob = getattr(self.portal, id)
        ob.setTitle('Test Image')
        ob.setImage(image_file)
        # Image is automatically published

        # Page (Document)
        id = self.portal.invokeFactory('Document', 'doc')
        ob = getattr(self.portal, id)
        ob.setTitle('Test Document')
        wtool.doActionFor(ob, 'publish')
示例#2
0
    def afterSetUp(self):
        super(FunctionalTestCase, self).afterSetUp()
        self.loginAsPortalOwner()
        wtool = getToolByName(self.portal, 'portal_workflow')

        # Image file
        pkg_home = Common.package_home({'__name__': 'collective.imagetags'})
        samplesdir = os.path.join(pkg_home, 'tests', 'samples')
        image_file = file(os.path.join(samplesdir, 'test_image.png')).read()
        
        # News item without image
        id = self.portal.invokeFactory('News Item', 'no-image')
        ob = getattr(self.portal, id)
        ob.setTitle('News item without image')
        wtool.doActionFor(ob, 'publish')
        
        # News item with image
        id = self.portal.invokeFactory('News Item', 'with-image')
        ob = getattr(self.portal, id)
        ob.setTitle('News item with image')
        ob.setImage(image_file)
        wtool.doActionFor(ob, 'publish')
        
        # Image
        id = self.portal.invokeFactory('Image', 'image')
        ob = getattr(self.portal, id)
        ob.setTitle('Test Image')
        ob.setImage(image_file)
        # Image is automatically published
        
        # Page (Document)
        id = self.portal.invokeFactory('Document', 'doc')
        ob = getattr(self.portal, id)
        ob.setTitle('Test Document')
        wtool.doActionFor(ob, 'publish')
示例#3
0
 def __init__(self, name, _prefix=None, **kw):
     if _prefix is None:
         _prefix = PREFIX
     elif not isinstance(_prefix, str):
         _prefix = Common.package_home(_prefix)
     args = (self, os.path.join(_prefix, name + '.dtml'))
     if '__name__' not in kw:
         kw['__name__'] = os.path.split(name)[-1]
     ClassicHTMLFile.inheritedAttribute('__init__')(*args, **kw)
示例#4
0
 def __init__(self, name, _prefix=None, **kw):
     if _prefix is None:
         _prefix = PREFIX
     elif type(_prefix) is not type(''):
         _prefix = Common.package_home(_prefix)
     args = (self, os.path.join(_prefix, name + '.dtml'))
     if '__name__' not in kw:
         kw['__name__'] = os.path.split(name)[-1]
     apply(ClassicHTMLFile.inheritedAttribute('__init__'), args, kw)
示例#5
0
 def __init__(self, name, _prefix=None, **kw):
     if _prefix is None:
         _prefix = PREFIX
     elif type(_prefix) is not type(""):
         _prefix = Common.package_home(_prefix)
     args = (self, os.path.join(_prefix, name + ".dtml"))
     if "__name__" not in kw:
         kw["__name__"] = os.path.split(name)[-1]
     apply(ClassicHTMLFile.inheritedAttribute("__init__"), args, kw)
示例#6
0
 def __init__(self, name, _prefix=None, **kw):
     if _prefix is None:
         _prefix = PREFIX
     elif not isinstance(_prefix, str):
         _prefix = Common.package_home(_prefix)
     args = (self, os.path.join(_prefix, name + '.dtml'))
     if '__name__' not in kw:
         kw['__name__'] = os.path.split(name)[-1]
     ClassicHTMLFile.inheritedAttribute('__init__')(*args, **kw)
示例#7
0
 def setup_pythonpath(self):
     pkg_home = appcommon.package_home({'__name__': self.package})
     basedir = os.path.join(pkg_home, self.extralibs)
     if not os.path.isdir(basedir):
         return []
     
     self.extralibs_configured = \
         [os.path.basename(x) 
          for x in setup_basedir_pythonpath(basedir)]
         
     return self.extralibs_configured
示例#8
0
def test_suite():
    suite = unittest.TestSuite()

    suite.addTest(
        ztc.FunctionalDocFileSuite('plone-video.txt',
                                   package='p4a.plonevideo',
                                   optionflags=doctest.ELLIPSIS
                                   | doctest.NORMALIZE_WHITESPACE,
                                   test_class=ptc.FunctionalTestCase))

    suite.addTest(
        ztc.FunctionalDocFileSuite('syndication.txt',
                                   package='p4a.plonevideo',
                                   optionflags=doctest.ELLIPSIS,
                                   test_class=ptc.FunctionalTestCase))

    import p4a.video.tests
    pkg_home = Common.package_home({'__name__': 'p4a.video.tests'})
    samplesdir = os.path.join(pkg_home, 'samples')

    # More quicktime samples here:
    # http://docs.info.apple.com/article.html?artnum=75424

    SAMPLES = (
        ('sample_sorenson.mov', 'video/quicktime',
         dict(width=190, height=240, duration=5.0)),
        ('sample_mpeg4.mp4', 'video/mp4',
         dict(width=190, height=240, duration=4.9666670000000002)),
        ('barsandtone.flv', 'video/x-flv',
         dict(width=360, height=288, duration=6.0)),
        ('sample_wmv.wmv', 'video/x-ms-wmv',
         dict(width=video_ifaces.IVideo['width'].default,
              height=video_ifaces.IVideo['height'].default,
              duration=5.7729999999999997)),
    )

    for relsamplefile, mimetype, samplefields in SAMPLES:

        class MediaTestCase(ptc.FunctionalTestCase):
            required_mimetype = mimetype
            samplefile = os.path.join(samplesdir, relsamplefile)
            file_content_type = 'File'
            fields = samplefields

        test = ztc.FunctionalDocFileSuite('plone-video-impl.txt',
                                          package='p4a.plonevideo',
                                          optionflags=doctest.ELLIPSIS,
                                          test_class=MediaTestCase)

        suite.addTest(test)

    return suite
def test_suite():
    suite = unittest.TestSuite()

    suite.addTest(
        ztc.FunctionalDocFileSuite('plone-audio.txt',
                                   package='p4a.ploneaudio',
                                   optionflags=doctest.ELLIPSIS,
                                   test_class=ptc.FunctionalTestCase))

    suite.addTest(
        ztc.FunctionalDocFileSuite('syndication-integration.txt',
                                   package='p4a.ploneaudio',
                                   optionflags=doctest.ELLIPSIS,
                                   test_class=ptc.FunctionalTestCase))

    suite.addTest(
        ztc.FunctionalDocFileSuite('browser.txt',
                                   package='p4a.ploneaudio',
                                   optionflags=doctest.ELLIPSIS,
                                   test_class=ptc.FunctionalTestCase))

    import p4a.audio.tests
    pkg_home = Common.package_home({'__name__': 'p4a.audio.tests'})
    samplesdir = os.path.join(pkg_home, 'samples')

    fields = dict(
        title=u'Test of the Emercy Broadcast System',
        artist=u'Rocky Burt',
        album=u'Emergencies All Around Us',
    )
    SAMPLES = (
        (os.path.join(samplesdir, 'test-full.mp3'), 'audio/mpeg', fields),
        (os.path.join(samplesdir, 'test-full.ogg'), 'application/ogg', fields),
        (os.path.join(samplesdir, 'test-no-images.mp3'), 'audio/mpeg', fields),
    )

    for relsamplefile, mimetype, samplefields in SAMPLES:

        class MediaTestCase(ptc.FunctionalTestCase):
            required_mimetype = mimetype
            samplefile = os.path.join(samplesdir, relsamplefile)
            file_content_type = 'File'
            fields = samplefields

        test = ztc.FunctionalDocFileSuite('plone-audio-impl.txt',
                                          package='p4a.ploneaudio',
                                          optionflags=doctest.ELLIPSIS,
                                          test_class=MediaTestCase)

        suite.addTest(test)

    return suite
def test_suite():
    from unittest import TestSuite

    suite = TestSuite()

    if has_plone():
        import os
        from App import Common
        from Testing.ZopeTestCase.zopedoctest import ZopeDocFileSuite
        from p4a.audiopatch.tests.ploneintegration import testclass_builder
        from Products.PloneTestCase import layer

        pkg_home = Common.package_home({'__name__': 'p4a.audiopatch.tests'})
        samplesdir = os.path.join(pkg_home, 'samples')


	from p4a.audio.mp3.thirdparty import eyeD3
		
	samplefile = os.path.join(samplesdir, 'test-cyrrilic.mp3')
	mimetype = 'audio/mpeg'	
	encoding = 'WINDOWS-1251'
	
	t = eyeD3.Tag()
	t.link(samplefile)
	
	eyeD3_encoding = 'latin_1'

        fields = dict(
            title=t.getTitle().encode(eyeD3_encoding).decode(encoding),
            artist=t.getArtist().encode(eyeD3_encoding).decode(encoding),
            album=t.getAlbum().encode(eyeD3_encoding).decode(encoding),
            )

	suite.addTest(ZopeDocFileSuite('plone-audio-impl.txt', package='p4a.audiopatch',
		test_class=testclass_builder(samplefile=samplefile,
					required_mimetype=mimetype,
					file_content_type='File',
					fields=fields,
					tag_encoding=encoding,
					eyeD3_encoding=eyeD3_encoding)
	)
	)


        suite.layer = layer.ZCMLLayer

    return suite
示例#11
0
    def afterSetUp(self):
        super(FunctionalTestCase, self).afterSetUp()
        self.loginAsPortalOwner()
        wtool = getToolByName(self.portal, 'portal_workflow')
        
        # Menu Folder
        id = self.portal.invokeFactory('Folder', 'menu')
        ob = getattr(self.portal, id)
        ob.setTitle('Menu folder')
        wtool.doActionFor(ob, 'publish')
        menu = ob
        self.menu = menu
        
        # First item in menu: an internal link to home
        id = menu.invokeFactory('Link', 'home-link')
        ob = getattr(menu, id)
        ob.setTitle('Home')
        ob.setRemoteUrl('/')
        wtool.doActionFor(ob, 'publish')
        elink = ob

        # Get image file
        pkg_home = Common.package_home({'__name__': 'collective.collage.megamenu'})
        samplesdir = os.path.join(pkg_home, 'tests', 'samples')
        image_file = file(os.path.join(samplesdir, 'test_image.png')).read()

        # Image
        id = self.portal.invokeFactory('Image', 'image')
        ob = getattr(self.portal, id)
        ob.setTitle('Test image')
        ob.setDescription('Dummy description for image')
        ob.setImage(image_file)
        # Image is automatically published
        image = ob
        
        # News item with image
        id = self.portal.invokeFactory('News Item', 'news-item')
        ob = getattr(self.portal, id)
        ob.setTitle('Test news item')
        ob.setDescription('Dummy description for news item')
        ob.setImage(image_file)
        wtool.doActionFor(ob, 'publish')
        ni = ob
        
        # Page (Document)
        id = self.portal.invokeFactory('Document', 'doc')
        ob = getattr(self.portal, id)
        ob.setTitle('Test document')
        ob.setDescription('Dummy description for document')
        wtool.doActionFor(ob, 'publish')
        doc = ob
        
        # Folder 1
        id = self.portal.invokeFactory('Folder', 'folder-1')
        ob = getattr(self.portal, id)
        ob.setTitle('Test folder #1')
        ob.setDescription('Dummy description for folder 1')
        wtool.doActionFor(ob, 'publish')
        folder1 = ob

        # Folder 2
        id = self.portal.invokeFactory('Folder', 'folder-2')
        ob = getattr(self.portal, id)
        ob.setTitle('Test folder #2')
        ob.setDescription('Dummy description for folder 2')
        wtool.doActionFor(ob, 'publish')
        folder2 = ob
        
        # External link
        id = self.portal.invokeFactory('Link', 'external-link')
        ob = getattr(self.portal, id)
        ob.setTitle('External link')
        ob.setDescription('External link to plone.org')
        ob.setRemoteUrl('http://plone.org/')
        wtool.doActionFor(ob, 'publish')
        elink = ob
        
        # Internal link
        id = self.portal.invokeFactory('Link', 'internal-link')
        ob = getattr(self.portal, id)
        ob.setTitle('Internal link')
        ob.setDescription('Internal link to no-where')
        ob.setRemoteUrl('/no-where')
        wtool.doActionFor(ob, 'publish')
        ilink = ob

        # Pre-build a Collage with aliases for each of the just created objects
        # and set the layout
        id = menu.invokeFactory('Collage', 'collage')
        collage = getattr(menu, id)
        collage.setTitle('Collage')
        wtool.doActionFor(collage, 'publish')
        self.collage = collage

        # Row & first column
        id = collage.invokeFactory('CollageRow', '1')
        row = getattr(collage, id)
        manager = IDynamicViewManager(row)
        manager.setLayout('menu')
        id = row.invokeFactory('CollageColumn', '1')
        column = getattr(row, id)
        manager = IDynamicViewManager(column)
        manager.setLayout('menu')
        
        # Alias for image
        id = column.invokeFactory('CollageAlias', 'alias-1')
        alias1 = getattr(column, id)
        alias1.set_target(image.UID())
        manager = IDynamicViewManager(alias1)
        manager.setLayout('menu')
        manager.setSkin('collage-megamenu-highlight')

        # Alias for document
        id = column.invokeFactory('CollageAlias', 'alias-2')
        alias2 = getattr(column, id)
        alias2.set_target(doc.UID())
        manager = IDynamicViewManager(alias2)
        manager.setLayout('menu')
        manager.setSkin('collage-megamenu-title')
        
        # Alias folder 1
        id = column.invokeFactory('CollageAlias', 'alias-3')
        alias3 = getattr(column, id)
        alias3.set_target(folder1.UID())
        manager = IDynamicViewManager(alias3)
        manager.setLayout('menu')

        # Alias for folder 2
        id = column.invokeFactory('CollageAlias', 'alias-4')
        alias4 = getattr(column, id)
        alias4.set_target(folder2.UID())
        manager = IDynamicViewManager(alias4)
        manager.setLayout('menu')
        
        # Alias for external link
        id = column.invokeFactory('CollageAlias', 'alias-5')
        alias5 = getattr(column, id)
        alias5.set_target(elink.UID())
        manager = IDynamicViewManager(alias5)
        manager.setLayout('menu')

        # Alias for internal link
        id = column.invokeFactory('CollageAlias', 'alias-6')
        alias6 = getattr(column, id)
        alias6.set_target(ilink.UID())
        manager = IDynamicViewManager(alias6)
        manager.setLayout('menu') 
        
        # Second column to add an intro layout
        id = row.invokeFactory('CollageColumn', '2')
        column = getattr(row, id)
        manager = IDynamicViewManager(column)
        manager.setLayout('menu')
        # Alias for news item intro
        id = column.invokeFactory('CollageAlias', 'alias-7')
        alias7 = getattr(column, id)
        alias7.set_target(ni.UID())
        manager = IDynamicViewManager(alias7)
        manager.setLayout('intro')
        
        # Alternate menu with just one link
        id = self.portal.invokeFactory('Folder', 'other-menu')
        ob = getattr(self.portal, id)
        ob.setTitle('Alternative menu')
        wtool.doActionFor(ob, 'publish')
        self.other_menu = ob
        
        # Another internal link
        id = self.other_menu.invokeFactory('Link', 'another-link')
        ob = getattr(self.other_menu, id)
        ob.setTitle('Another link')
        ob.setDescription('Internal link to somewhere')
        ob.setRemoteUrl('/somewhere')
        wtool.doActionFor(ob, 'publish')