Пример #1
0
    def setUpPloneSite(self, portal):
        if DEXTERITY_ONLY:
            self.applyProfile(portal, 'plone.app.contenttypes:default')

        self.applyProfile(portal, 'collective.cover:default')
        self.applyProfile(portal, 'collective.cover:testfixture')
        self.applyProfile(portal, 'covertile.cycle2:default')

        # setup test content
        create_standard_content_for_tests(portal)
        set_image_field(portal['my-image1'], generate_jpeg(900, 400))
        set_image_field(portal['my-image2'], generate_jpeg(900, 400))
    def test_basic_tile_render(self):
        obj = self.portal['my-news-item']
        obj.setSubject(['subject1', 'subject2'])
        obj.effective_date = DateTime()
        obj.setImage(generate_jpeg(128, 128))
        obj.reindexObject()

        self.tile.populate_with_object(obj)
        rendered = self.tile()

        # the title and a link to the original object must be there
        self.assertIn('Test news item', rendered)
        self.assertIn(obj.absolute_url(), rendered)

        # the description must be there
        self.assertIn("This news item was created for testing purposes",
                      rendered)

        # the localized time must be there
        utils = getMultiAdapter((self.portal, self.request), name=u'plone')
        date = utils.toLocalizedTime(obj.Date(), True)
        self.assertIn(date, rendered)

        # the tags must be there
        self.assertIn('subject1', rendered)
        self.assertIn('subject2', rendered)
Пример #3
0
    def test_basic_tile_render(self):
        obj = self.portal['my-news-item']
        obj.setSubject(['subject1', 'subject2'])
        obj.effective_date = DateTime()
        obj.setImage(generate_jpeg(128, 128))
        obj.reindexObject()

        self.tile.populate_with_object(obj)
        rendered = self.tile()

        # the title and a link to the original object must be there
        self.assertIn('Test news item', rendered)
        self.assertIn(obj.absolute_url(), rendered)

        # the description must be there
        self.assertIn(
            "This news item was created for testing purposes", rendered)

        # the localized time must be there
        utils = getMultiAdapter((self.portal, self.request), name=u'plone')
        date = utils.toLocalizedTime(obj.Date(), True)
        self.assertIn(date, rendered)

        # the tags must be there
        self.assertIn('subject1', rendered)
        self.assertIn('subject2', rendered)
Пример #4
0
    def test_basic_tile_render(self):
        obj = self.portal['my-news-item']
        obj.setSubject(['subject1', 'subject2'])
        obj.effective_date = DateTime()
        obj.setImage(generate_jpeg(128, 128))
        obj.reindexObject()

        self.tile.populate_with_object(obj)
        rendered = self.tile()

        # the title and a link to the original object must be there
        self.assertIn('Test news item', rendered)
        self.assertIn(obj.absolute_url(), rendered)

        # the description must be there
        self.assertIn(
            'This news item was created for testing purposes', rendered)

        # the localized time must be there
        date = api.portal.get_localized_time(obj.Date(), long_format=True)
        self.assertIn(date, rendered)

        # the tags must be there
        self.assertIn('subject1', rendered)
        self.assertIn('subject2', rendered)
Пример #5
0
    def test_basic_tile_image(self):
        obj = self.portal['my-news-item']
        obj.setImage(generate_jpeg(128, 128))
        obj.reindexObject()

        self.tile.populate_with_object(obj)
        rendered = self.tile()

        self.assertIn('test/@@images', rendered)
Пример #6
0
 def test_image_traversal(self):
     obj = self.portal['my-image']
     obj.setImage(generate_jpeg(1024, 768))
     self.tile.populate_with_object(obj)
     image = self.layer['portal'].restrictedTraverse('@@%s/%s/@@images' % (
         'collective.cover.image',
         'test-image-tile',
     )).publishTraverse(self.request, 'image')
     img = Image.open(image.index_html())
     self.assertEqual(img.size, (1024, 768))
Пример #7
0
 def test_image_scale(self):
     obj = self.portal['my-image']
     obj.setImage(generate_jpeg(1024, 768))
     self.tile.populate_with_object(obj)
     scales = self.layer['portal'].restrictedTraverse('@@%s/%s/@@images' %
                                                      ('collective.cover.image',
                                                       'test-image-tile',))
     scale_mini = scales.scale('image', scale='mini')
     img = Image.open(scale_mini.index_html())
     self.assertEqual(img.size, (200, 150))
Пример #8
0
 def test_image_traversal(self):
     obj = self.portal['my-image']
     obj.setImage(generate_jpeg(1024, 768))
     self.tile.populate_with_object(obj)
     image = self.layer['portal'].restrictedTraverse(
         '@@%s/%s/@@images' %
         ('collective.cover.image',
          'test-image-tile',)).publishTraverse(self.request, 'image')
     img = Image.open(image.index_html())
     self.assertEqual(img.size, (1024, 768))
Пример #9
0
    def test_basic_tile_image(self):
        obj = self.portal["my-news-item"]
        obj.setImage(generate_jpeg(128, 128))
        obj.reindexObject()

        self.tile.populate_with_object(obj)
        rendered = self.tile()

        # old code copy the image
        self.assertNotIn("test-basic-tile/@@images", rendered)
Пример #10
0
 def test_image_scale(self):
     obj = self.portal['my-image']
     obj.setImage(generate_jpeg(1024, 768))
     self.tile.populate_with_object(obj)
     scales = self.layer['portal'].restrictedTraverse('@@%s/%s/@@images' % (
         'collective.cover.image',
         'test-image-tile',
     ))
     scale_mini = scales.scale('image', scale='mini')
     img = Image.open(scale_mini.index_html())
     self.assertEqual(img.size, (200, 150))
Пример #11
0
 def test_alt_atribute_present_in_image(self):
     """Object's title must be displayed in image alt attribute.
     See: https://github.com/collective/collective.cover/issues/182
     """
     obj = self.portal["my-news-item"]
     obj.setImage(generate_jpeg(128, 128))
     obj.reindexObject()
     self.tile.populate_with_object(obj)
     tile_conf_adapter = getMultiAdapter((self.tile.context, self.request, self.tile), ITilesConfigurationScreen)
     tile_conf_adapter.set_configuration({"image": {"visibility": "on", "imgsize": "large"}})
     rendered = self.tile()
     self.assertIn('alt="Test news item"', rendered)
Пример #12
0
 def test_alt_atribute_present_in_image(self):
     """Object's title must be displayed in image alt attribute.
     See: https://github.com/collective/collective.cover/issues/182
     """
     obj = self.portal['my-news-item']
     obj.setImage(generate_jpeg(128, 128))
     obj.reindexObject()
     self.tile.populate_with_object(obj)
     tile_conf_adapter = getMultiAdapter((self.tile.context, self.request, self.tile),
                                         ITilesConfigurationScreen)
     tile_conf_adapter.set_configuration({'image': {'visibility': 'on', 'imgsize': 'large'}})
     rendered = self.tile()
     self.assertIn('alt="Test news item"', rendered)
 def setUpPloneSite(self, portal):
     # Install into Plone site using portal_setup
     # self.applyProfile(portal, 'plone.app.linkintegrity:default')
     super(LinkintegrityFixture, self).setUpPloneSite(portal)
     setRoles(portal, TEST_USER_ID, ['Manager'])
     fti = DexterityFTI('My Dexterity Item')
     portal.portal_types._setObject('My Dexterity Item', fti)
     fti.klass = 'plone.dexterity.content.Item'
     fti.schema = 'collective.cover.tests.test_linkintegrity.IMyDexterityItem'
     fti.behaviors = ('plone.app.referenceablebehavior.referenceable.IReferenceable',)
     fti = DexterityFTI('Non referenciable Dexterity Item')
     portal.portal_types._setObject('Non referenciable Dexterity Item', fti)
     fti.klass = 'plone.dexterity.content.Item'
     fti.schema = 'collective.cover.tests.test_linkintegrity.IMyDexterityItem'
     # Create some dexterity items to test with it
     portal.invokeFactory(
         'My Dexterity Item', id='dexterity_item1', title='Dexterity Item 1')
     portal.invokeFactory(
         'My Dexterity Item', id='dexterity_item2', title='Dexterity Item 2')
     portal.invokeFactory(
         'Non referenciable Dexterity Item',
         id='nonreferenciable_dexterity_item1',
         title='Non referenciable Dexterity Item 1'
     )
     portal.invokeFactory(
         'Non referenciable Dexterity Item',
         id='nonreferenciable_dexterity_item2',
         title='Non referenciable Dexterity Item 2'
     )
     # Create an AT Image
     image = generate_jpeg(50, 50)
     portal.invokeFactory(
         'Image', id='image1', title='Test Image 1', image=image)
     portal.invokeFactory('collective.cover.content', 'cover1')
     # Documents
     text = '<html> <body> a test page </body> </html>'
     portal.invokeFactory(
         'Document', id='doc1', title='Test Page 1', text=text)
     text = '<html> <body> another test page </body> </html>'
     portal.invokeFactory(
         'Document', id='doc2', title='Test Page 2', text=text)
     text = '<html> <body> a test page in a subfolder </body> </html>'
     portal.invokeFactory('Folder', id='folder1', title='Test Folder 1')
     portal.folder1.invokeFactory(
         'Document', id='doc3', title='Test Page 3', text=text)