Ejemplo n.º 1
0
 def testDisabled(self):
     registry = getUtility(IRegistry)
     settings = registry.forInterface(ISocialMediaSchema, prefix="plone",
                                      check=False)
     settings.share_social_data = False
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertEquals(len(viewlet.tags), 0)
Ejemplo n.º 2
0
 def testLogo(self):
     viewlet = SocialTagsViewlet(self.news, self.app.REQUEST, None)
     viewlet.update()
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:image', 'http://nohost/plone/logo.png'))
     self.assertFalse(self.tagFound(viewlet, 'itemprop'))
     self.assertTrue(self.bodyTagFound(
         viewlet, 'itemprop', 'image', 'http://nohost/plone/logo.png'))
Ejemplo n.º 3
0
 def testBasicTags(self):
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertTrue(self.tagFound(viewlet, 'name', 'twitter:card', "summary"))
     self.assertTrue(self.tagFound(viewlet, 'name', 'twitter:title',
                                   viewlet.page_title))
     self.assertTrue(self.tagFound(viewlet, 'property', 'og:site_name',
                                   viewlet.site_title_setting))
Ejemplo n.º 4
0
 def testDisabled(self):
     registry = getUtility(IRegistry)
     settings = registry.forInterface(
         ISocialMediaSchema, prefix='plone', check=False)
     settings.share_social_data = False
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertEquals(len(viewlet.tags), 0)
Ejemplo n.º 5
0
 def testLogo(self):
     viewlet = SocialTagsViewlet(self.news, self.app.REQUEST, None)
     viewlet.update()
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:image', 'http://nohost/plone/logo.png'))
     self.assertFalse(self.tagFound(viewlet, 'itemprop'))
     self.assertTrue(self.bodyTagFound(
         viewlet, 'itemprop', 'image', 'http://nohost/plone/logo.png'))
Ejemplo n.º 6
0
 def testDisabledForLoggedUser(self):
     login(self.portal, TEST_USER_NAME)
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertEquals(len(viewlet.tags), 0)
     # clear cache to prevent memoize
     cache = IAnnotations(self.app.REQUEST)
     key = 'plone.memoize'
     cache[key] = {}
     logout()
     viewlet.update()
     self.assertTrue(len(viewlet.tags) > 1)
Ejemplo n.º 7
0
    def testIncludeSocialSettings(self):
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISocialMediaSchema, prefix="plone",
                                         check=False)
        settings.twitter_username = u'foobar'
        settings.facebook_app_id = u'foobar'
        settings.facebook_username = u'foobar'

        viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
        viewlet.update()
        self.assertTrue(self.tagFound(viewlet, 'name', 'twitter:site', "@foobar"))
        self.assertTrue(self.tagFound(viewlet, 'property', 'fb:app_id', 'foobar'))
        self.assertTrue(
            self.tagFound(viewlet, 'property',
                          'og:article:publisher', 'https://www.facebook.com/foobar'))
Ejemplo n.º 8
0
 def testBasicItemProps(self):
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     description = self.folder.Description()
     folder_url = self.folder.absolute_url()
     # No Twitter
     self.assertFalse(self.bodyTagFound(viewlet, 'name'))
     # No OpenGraph/Facebook
     self.assertFalse(self.bodyTagFound(viewlet, 'property'))
     # schema.org itemprops
     self.assertTrue(self.bodyTagFound(
         viewlet, 'itemprop', 'name', viewlet.page_title))
     self.assertTrue(self.bodyTagFound(
         viewlet, 'itemprop', 'description', description))
     self.assertTrue(self.bodyTagFound(
         viewlet, 'itemprop', 'url', folder_url))
Ejemplo n.º 9
0
 def testIncludeSocialSettings(self):
     registry = getUtility(IRegistry)
     settings = registry.forInterface(
         ISocialMediaSchema, prefix='plone', check=False)
     settings.twitter_username = '******'
     settings.facebook_app_id = 'foobar'
     settings.facebook_username = '******'
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertTrue(self.tagFound(
         viewlet, 'name', 'twitter:site', '@foobar'))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'fb:app_id', 'foobar'))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:article:publisher',
         'https://www.facebook.com/foobar'))
Ejemplo n.º 10
0
 def testBasicItemProps(self):
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     description = self.folder.Description()
     folder_url = self.folder.absolute_url()
     # No Twitter
     self.assertFalse(self.bodyTagFound(viewlet, 'name'))
     # No OpenGraph/Facebook
     self.assertFalse(self.bodyTagFound(viewlet, 'property'))
     # schema.org itemprops
     self.assertTrue(
         self.bodyTagFound(viewlet, 'itemprop', 'name', viewlet.page_title))
     self.assertTrue(
         self.bodyTagFound(viewlet, 'itemprop', 'description', description))
     self.assertTrue(
         self.bodyTagFound(viewlet, 'itemprop', 'url', folder_url))
Ejemplo n.º 11
0
 def testBasicTags(self):
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     description = self.folder.Description()
     folder_url = self.folder.absolute_url()
     # Twitter
     self.assertTrue(self.tagFound(
         viewlet, 'name', 'twitter:card', "summary"))
     # OpenGraph/Facebook
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:site_name', viewlet.site_title_setting))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:title', viewlet.page_title))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:description', description))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:url', folder_url))
     # No schema.org itemprops
     self.assertFalse(self.tagFound(viewlet, 'itemprop'))
Ejemplo n.º 12
0
 def testBasicTags(self):
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     description = self.folder.Description()
     folder_url = self.folder.absolute_url()
     # Twitter
     self.assertTrue(self.tagFound(
         viewlet, 'name', 'twitter:card', "summary"))
     # OpenGraph/Facebook
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:site_name', viewlet.site_title_setting))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:title', viewlet.page_title))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:description', description))
     self.assertTrue(self.tagFound(
         viewlet, 'property', 'og:url', folder_url))
     # No schema.org itemprops
     self.assertFalse(self.tagFound(viewlet, 'itemprop'))
Ejemplo n.º 13
0
 def testDisabledForLoggedUser(self):
     login(self.portal, TEST_USER_NAME)
     viewlet = SocialTagsViewlet(self.folder, self.app.REQUEST, None)
     viewlet.update()
     self.assertEquals(len(viewlet.tags), 0)
     # clear cache to prevent memoize
     cache = IAnnotations(self.app.REQUEST)
     key = 'plone.memoize'
     cache[key] = {}
     logout()
     viewlet.update()
     self.assertTrue(len(viewlet.tags) > 1)