Esempio n. 1
0
    def test_get_should_return_existing_tag(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('Karen Duve', tagger.get(u'☃Karen Duve').label)
Esempio n. 2
0
    def test_contains_should_return_true_for_existing_tag(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        self.assertIn(u'☃Karen Duve', tagger)
Esempio n. 3
0
    def test_contains_should_return_true_for_existing_tag(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        self.assertIn(u'☃Karen Duve', tagger)
Esempio n. 4
0
    def test_get_should_return_existing_tag(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('Karen Duve', tagger.get(u'☃Karen Duve').label)
Esempio n. 5
0
 def test_converts_storystreams_correctly(self):
     content = create_testcontent()
     source = zeit.cms.content.interfaces.ICommonMetadata[
         'storystreams'].value_type.source(None)
     content.storystreams = (source.find('test'), )
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(['test'], data['payload']['document']['storystreams'])
Esempio n. 6
0
 def test_to_xml_returns_empty_when_keyword_DAV_property_is_malformed(self):
     content = create_testcontent()
     dav = zeit.connector.interfaces.IWebDAVProperties(content)
     dav[('rankedTags',
          'http://namespaces.zeit.de/CMS/tagging')] = "<foobar/>"
     tagger = Tagger(content)
     self.assertEqual(Tagger.EMPTY_NODE, tagger.to_xml())
Esempio n. 7
0
 def test_converts_seo_properties(self):
     content = create_testcontent()
     seo = zeit.seo.interfaces.ISEO(content)
     seo.meta_robots = 'noindex, follow,noarchive'
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(['noindex', 'follow', 'noarchive'],
                      data['payload']['seo']['robots'])
Esempio n. 8
0
 def test_to_xml_returns_empty_when_keyword_DAV_property_is_malformed(self):
     content = create_testcontent()
     dav = zeit.connector.interfaces.IWebDAVProperties(content)
     dav[('rankedTags',
          'http://namespaces.zeit.de/CMS/tagging')] = "<foobar/>"
     tagger = Tagger(content)
     self.assertEqual(Tagger.EMPTY_NODE, tagger.to_xml())
Esempio n. 9
0
 def test_converts_push_config(self):
     content = create_testcontent()
     push = zeit.push.interfaces.IPushMessages(content)
     push.message_config = [
         {
             'type': 'facebook',
             'account': 'fb-test',
             'enabled': False
         },
         {
             'type': 'facebook',
             'account': 'fb-magazin',
             'enabled': False
         },
         {
             'type': 'mobile',
             'payload_template': 'mytemplate.json',
             'enabled': True
         },
     ]
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(
         {
             'facebook': {
                 'account': ['fb-test', 'fb-magazin']
             },
             'mobile': {
                 'payload_template': ['mytemplate.json']
             },
         }, data['payload']['push'])
Esempio n. 10
0
 def test_no_disabled_tags_should_return_empty_tuple(self):
     content = create_testcontent()
     tagger = Tagger(content)
     self.assertEqual((), tagger.disabled)
     dav = zeit.connector.interfaces.IWebDAVProperties(content)
     dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
     dav[dav_key] = u''
     self.assertEqual((), tagger.disabled)
Esempio n. 11
0
    def test_iter_includes_tags_with_and_without_uuids(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag>Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual([u'☃Karen Duve', u'☃Berlin'], list(tagger))
Esempio n. 12
0
 def test_converts_seo_properties(self):
     content = create_testcontent()
     seo = zeit.seo.interfaces.ISEO(content)
     seo.meta_robots = 'noindex, follow,noarchive'
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(
         ['noindex', 'follow', 'noarchive'],
         data['payload']['seo']['robots'])
Esempio n. 13
0
 def test_converts_storystreams_correctly(self):
     content = create_testcontent()
     source = zeit.cms.content.interfaces.ICommonMetadata[
         'storystreams'].value_type.source(None)
     content.storystreams = (source.find('test'),)
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(['test'],
                      data['payload']['document']['storystreams'])
Esempio n. 14
0
    def test_tag_should_have_url_value(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin" url_value="dickesb">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('berlin', tagger[u'☃Berlin'].url_value)
Esempio n. 15
0
 def test_no_disabled_tags_should_return_empty_tuple(self):
     content = create_testcontent()
     tagger = Tagger(content)
     self.assertEqual((), tagger.disabled)
     dav = zeit.connector.interfaces.IWebDAVProperties(content)
     dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
     dav[dav_key] = u''
     self.assertEqual((), tagger.disabled)
Esempio n. 16
0
 def test_drops_empty_properties(self):
     content = create_testcontent()
     props = zeit.connector.interfaces.IWebDAVProperties(content)
     props[('page', 'http://namespaces.zeit.de/CMS/document')] = None
     props[('reported_on', 'http://namespaces.zeit.de/CMS/vgwort')] = ''
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertNotIn('page', data['payload']['document'])
     self.assertNotIn('vgwort', data['payload'])
Esempio n. 17
0
    def test_update_should_keep_pinned_tags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>""")
        tagger = Tagger(content)
        tagger.set_pinned([u'☃Karen Duve'])
        tagger.update()
        self.assertEqual([u'☃Karen Duve'], list(tagger))
Esempio n. 18
0
 def test_checkin_should_not_fail_with_no_tags_and_no_rankedTags_element(
         self):
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = create_testcontent()
     with checked_out(repository['content']):
         # cycle
         pass
Esempio n. 19
0
 def test_tagger_raises_error_on_keys_and_items(self):
     # We do not use keys and items yet but the interface requires them.
     content = create_testcontent()
     tagger = Tagger(content)
     with self.assertRaises(NotImplementedError):
         tagger.keys()
     with self.assertRaises(NotImplementedError):
         tagger.items()
Esempio n. 20
0
 def test_tagger_raises_error_on_keys_and_items(self):
     # We do not use keys and items yet but the interface requires them.
     content = create_testcontent()
     tagger = Tagger(content)
     with self.assertRaises(NotImplementedError):
         tagger.keys()
     with self.assertRaises(NotImplementedError):
         tagger.items()
Esempio n. 21
0
    def test_update_should_keep_pinned_tags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>""")
        tagger = Tagger(content)
        tagger.set_pinned([u'☃Karen Duve'])
        tagger.update()
        self.assertEqual([u'☃Karen Duve'], list(tagger))
Esempio n. 22
0
    def test_tagger_should_get_tags_from_content(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual(set([u'☃Berlin', u'☃Karen Duve']), set(tagger))
Esempio n. 23
0
 def test_drops_empty_properties(self):
     content = create_testcontent()
     props = zeit.connector.interfaces.IWebDAVProperties(content)
     props[('page', 'http://namespaces.zeit.de/CMS/document')] = None
     props[('reported_on', 'http://namespaces.zeit.de/CMS/vgwort')] = ''
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertNotIn('page', data['payload']['document'])
     self.assertNotIn('vgwort', data['payload'])
Esempio n. 24
0
 def test_checkin_should_not_fail_with_no_tags_and_no_rankedTags_element(
         self):
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = create_testcontent()
     with checked_out(repository['content']):
         # cycle
         pass
Esempio n. 25
0
    def test_tag_should_have_entity_type(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin" type="Location">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('Location', tagger[u'Location☃Berlin'].entity_type)
Esempio n. 26
0
    def test_to_xml_should_return_inner_rankedTags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        node = tagger.to_xml()
        self.assertEqual('rankedTags', node.tag)
Esempio n. 27
0
    def test_delitem_should_remove_tag(self):
        content = create_testcontent()
        # use an umlaut to exercise serialization
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Düve</tag>
""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Düve']
        self.assertNotIn(u'☃Karen Düve', tagger)
Esempio n. 28
0
    def test_iter_includes_tags_with_and_without_uuids(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag>Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual([u'☃Karen Duve', u'☃Berlin'], list(tagger))
Esempio n. 29
0
    def test_tag_should_have_url_value(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin" url_value="dickesb">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('berlin', tagger[u'☃Berlin'].url_value)
Esempio n. 30
0
    def test_tag_should_have_entity_type(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin" type="Location">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual('Location', tagger[u'Location☃Berlin'].entity_type)
Esempio n. 31
0
    def test_delitem_should_remove_tag(self):
        content = create_testcontent()
        # use an umlaut to exercise serialization
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Düve</tag>
""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Düve']
        self.assertNotIn(u'☃Karen Düve', tagger)
Esempio n. 32
0
    def test_tagger_should_get_tags_from_content(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        self.assertEqual(set([u'☃Berlin', u'☃Karen Duve']), set(tagger))
Esempio n. 33
0
 def test_converts_agencies(self):
     author = zeit.content.author.author.Author()
     author.firstname = u'William'
     author.lastname = u'Shakespeare'
     self.repository['author'] = author
     content = create_testcontent()
     content.agencies = [self.repository['author']]
     data = zeit.retresco.interfaces.ITMSRepresentation(content)()
     self.assertEqual(['http://xml.zeit.de/author'],
                      data['payload']['head']['agencies'])
Esempio n. 34
0
    def test_iter_should_be_sorted_by_document_order(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        self.assertEqual(
            [u'☃Berlin', u'☃Karen Duve', u'☃Fleisch'], list(tagger))
Esempio n. 35
0
    def test_ignores_xml_attributes_besides_entity_type(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag type="Snowpeople" url_value="url" uuid="uuid-tag">Snowman Tag</tag>
""")
        tagger = Tagger(content)
        snowman = tagger[u'Snowpeople☃Snowman Tag']
        self.assertEqual(
            [u'Snowman Tag', u'Snowpeople', u'snowman-tag'],
            [snowman.label, snowman.entity_type, snowman.url_value])
Esempio n. 36
0
 def test_no_tags_cause_rankedTags_element_to_be_removed_from_xml(self):
     content = create_testcontent()
     content.xml.head.rankedTags = 'bla bla bla'
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = content
     with checked_out(repository['content']):
         # cycle
         pass
     self.assertNotIn('rankedTags', repository['content'].xml.head.keys())
Esempio n. 37
0
 def test_no_tags_cause_rankedTags_element_to_be_removed_from_xml(self):
     content = create_testcontent()
     content.xml.head.rankedTags = 'bla bla bla'
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = content
     with checked_out(repository['content']):
         # cycle
         pass
     self.assertNotIn('rankedTags', repository['content'].xml.head.keys())
Esempio n. 38
0
    def test_update_with_option_should_not_clear_disabled_tags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Duve']
        tagger.update(clear_disabled=False)
        dav = zeit.connector.interfaces.IWebDAVProperties(content)
        dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
        self.assertEqual(u'☃Karen Duve', dav[dav_key])
Esempio n. 39
0
    def test_to_xml_should_return_inner_rankedTags(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        node = tagger.to_xml()
        self.assertEqual('rankedTags', node.tag)
Esempio n. 40
0
    def test_update_with_option_should_not_clear_disabled_tags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Duve']
        tagger.update(clear_disabled=False)
        dav = zeit.connector.interfaces.IWebDAVProperties(content)
        dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
        self.assertEqual(u'☃Karen Duve', dav[dav_key])
Esempio n. 41
0
    def test_update_should_pass_existing_tags_to_tms(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve" type="keyword">Karen Duve</tag>
<tag uuid="uid-berlin" type="location">Berlin</tag>""")
        tagger = Tagger(content)
        with mock.patch('zeit.retresco.connection.TMS._request') as request:
            tagger.update()
            data = request.call_args[1]['json']
            self.assertEqual(['Karen Duve'], data['rtr_keywords'])
            self.assertEqual(['Berlin'], data['rtr_locations'])
Esempio n. 42
0
    def test_iter_should_be_sorted_by_document_order(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        self.assertEqual([u'☃Berlin', u'☃Karen Duve', u'☃Fleisch'],
                         list(tagger))
Esempio n. 43
0
    def test_delitem_should_add_tag_to_disabled_list_in_dav(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Duve']

        dav = zeit.connector.interfaces.IWebDAVProperties(content)
        dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
        self.assertEqual(u'☃Karen Duve', dav[dav_key])
Esempio n. 44
0
    def test_given_keys_differ_from_existing_keys_should_raise(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        self.assertRaises(
            ValueError,
            lambda: tagger.updateOrder(['uid-berlin', 'uid-karenduve']))
Esempio n. 45
0
    def test_delitem_should_add_tag_to_disabled_list_in_dav(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
""")
        tagger = Tagger(content)
        del tagger[u'☃Karen Duve']

        dav = zeit.connector.interfaces.IWebDAVProperties(content)
        dav_key = ('disabled', 'http://namespaces.zeit.de/CMS/tagging')
        self.assertEqual(u'☃Karen Duve', dav[dav_key])
Esempio n. 46
0
    def test_tags_should_be_accessible_by_id(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        tag = tagger[u'☃Karen Duve']
        self.assertEqual(tagger, tag.__parent__)
        self.assertEqual(u'☃Karen Duve', tag.__name__)
        self.assertEqual('Karen Duve', tag.label)
Esempio n. 47
0
    def test_updateOrder_should_sort_tags(self):
        content = create_testcontent()
        self.set_tags(content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        tagger.updateOrder([u'☃Fleisch', u'☃Berlin', u'☃Karen Duve'])
        self.assertEqual(
            [u'☃Fleisch', u'☃Berlin', u'☃Karen Duve'], list(tagger))
Esempio n. 48
0
 def test_update_should_discard_disabled_tags(self):
     extract_keywords = 'zeit.retresco.connection.TMS.extract_keywords'
     with mock.patch(extract_keywords) as extract_keywords:
         extract_keywords.return_value = [Tag('Foo', ''), Tag('Bar', '')]
         content = create_testcontent()
         tagger = Tagger(content)
         tagger.update()
         self.assertEqual(2, len(tagger))
         del tagger[u'☃Foo']
         tagger.update()
         self.assertEqual([u'☃Bar'], list(tagger))
Esempio n. 49
0
    def test_ignores_xml_attributes_besides_entity_type(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag type="Snowpeople" url_value="url" uuid="uuid-tag">Snowman Tag</tag>
""")
        tagger = Tagger(content)
        snowman = tagger[u'Snowpeople☃Snowman Tag']
        self.assertEqual(
            [u'Snowman Tag', u'Snowpeople', u'snowman-tag'],
            [snowman.label, snowman.entity_type, snowman.url_value])
Esempio n. 50
0
 def test_existing_tags_should_cause_rankedTags_to_be_added_to_xml(self):
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = create_testcontent()
     with checked_out(repository['content']) as content:
         self.set_tags(content, """
 <tag uuid="uid-karenduve">Karen Duve</tag>
 <tag uuid="uid-berlin">Berlin</tag>
 """)
     self.assertEqual(
         ['Karen Duve', 'Berlin'],
         repository['content'].xml.head.rankedTags.getchildren())
Esempio n. 51
0
    def test_updateOrder_should_sort_tags_even_when_keys_are_generator(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        tagger.updateOrder(iter([u'☃Fleisch', u'☃Berlin', u'☃Karen Duve']))
        self.assertEqual([u'☃Fleisch', u'☃Berlin', u'☃Karen Duve'],
                         list(tagger))
Esempio n. 52
0
    def test_given_keys_differ_from_existing_keys_should_raise(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-berlin">Berlin</tag>
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-fleisch">Fleisch</tag>
""")
        tagger = Tagger(content)
        self.assertRaises(
            ValueError,
            lambda: tagger.updateOrder(['uid-berlin', 'uid-karenduve']))
Esempio n. 53
0
 def test_update_should_discard_disabled_tags(self):
     extract_keywords = 'zeit.retresco.connection.TMS.extract_keywords'
     with mock.patch(extract_keywords) as extract_keywords:
         extract_keywords.return_value = [
             Tag('Foo', ''), Tag('Bar', '')]
         content = create_testcontent()
         tagger = Tagger(content)
         tagger.update()
         self.assertEqual(2, len(tagger))
         del tagger[u'☃Foo']
         tagger.update()
         self.assertEqual([u'☃Bar'], list(tagger))
Esempio n. 54
0
    def test_tags_should_be_accessible_by_id(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve">Karen Duve</tag>
<tag uuid="uid-berlin">Berlin</tag>
""")
        tagger = Tagger(content)
        tag = tagger[u'☃Karen Duve']
        self.assertEqual(tagger, tag.__parent__)
        self.assertEqual(u'☃Karen Duve', tag.__name__)
        self.assertEqual('Karen Duve', tag.label)
Esempio n. 55
0
    def test_update_should_pass_existing_tags_to_tms(self):
        content = create_testcontent()
        self.set_tags(
            content, """
<tag uuid="uid-karenduve" type="keyword">Karen Duve</tag>
<tag uuid="uid-berlin" type="location">Berlin</tag>""")
        tagger = Tagger(content)
        with mock.patch('zeit.retresco.connection.TMS._request') as request:
            tagger.update()
            data = request.call_args[1]['json']
            self.assertEqual(['Karen Duve'], data['rtr_keywords'])
            self.assertEqual(['Berlin'], data['rtr_locations'])
Esempio n. 56
0
 def test_rankedTags_in_xml_should_be_updated_on_modified_event(self):
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = create_testcontent()
     with checked_out(repository['content']) as content:
         self.set_tags(content, """
 <tag uuid="uid-karenduve">Karen Duve</tag>
 <tag uuid="uid-berlin">Berlin</tag>
 """)
         zope.lifecycleevent.modified(content)
         self.assertEqual(
             ['Karen Duve', 'Berlin'],
             content.xml.head.rankedTags.getchildren())
Esempio n. 57
0
 def test_rankedTags_in_xml_should_be_updated_on_modified_event(self):
     repository = zope.component.getUtility(
         zeit.cms.repository.interfaces.IRepository)
     repository['content'] = create_testcontent()
     with checked_out(repository['content']) as content:
         self.set_tags(
             content, """
 <tag uuid="uid-karenduve">Karen Duve</tag>
 <tag uuid="uid-berlin">Berlin</tag>
 """)
         zope.lifecycleevent.modified(content)
         self.assertEqual(['Karen Duve', 'Berlin'],
                          content.xml.head.rankedTags.getchildren())
Esempio n. 58
0
    def test_iterating_values_calls_to_xml_only_once(self):
        # We do not want to reuse `__iter__` and `__getitem__` in values, since
        # that would call `_find_tag_node` & `to_xml` for *each* keyword.
        content = create_testcontent()
        tagger = Tagger(content)
        with mock.patch('zeit.retresco.tagger.Tagger.to_xml') as to_xml:
            to_xml.return_value = lxml.objectify.fromstring("""
<rankedTags>
    <tag uuid="uid-karenduve">Karen Duve</tag>
    <tag uuid="uid-berlin">Berlin</tag>
</rankedTags>""")
            self.assertEqual(2, len(list(tagger.values())))
            self.assertEqual(1, to_xml.call_count)
Esempio n. 59
0
    def test_iterating_values_calls_to_xml_only_once(self):
        # We do not want to reuse `__iter__` and `__getitem__` in values, since
        # that would call `_find_tag_node` & `to_xml` for *each* keyword.
        content = create_testcontent()
        tagger = Tagger(content)
        with mock.patch('zeit.retresco.tagger.Tagger.to_xml') as to_xml:
            to_xml.return_value = lxml.objectify.fromstring("""
<rankedTags>
    <tag uuid="uid-karenduve">Karen Duve</tag>
    <tag uuid="uid-berlin">Berlin</tag>
</rankedTags>""")
            self.assertEqual(2, len(list(tagger.values())))
            self.assertEqual(1, to_xml.call_count)
Esempio n. 60
0
 def test_links_to_topicpages_are_retrieved_from_tms(self):
     content = create_testcontent()
     tagger = Tagger(content)
     article_keywords = 'zeit.retresco.connection.TMS.get_article_keywords'
     with mock.patch(article_keywords) as article_keywords:
         tag1 = Tag('Foo', '')
         tag1.link = 'thema/foo'
         tag2 = Tag('Bar', '')
         article_keywords.return_value = [tag1, tag2]
         self.assertEqual({
             tag1.uniqueId: 'http://localhost/live-prefix/thema/foo',
             tag2.uniqueId: None,
         }, tagger.links)