Exemple #1
0
    def test_publishes_and_retracts_multiple_objects_in_single_script_call(
            self):
        c1 = zeit.cms.interfaces.ICMSContent(
            'http://xml.zeit.de/online/2007/01/Somalia')
        c2 = zeit.cms.interfaces.ICMSContent(
            'http://xml.zeit.de/online/2007/01/eta-zapatero')
        IPublishInfo(c1).urgent = True
        IPublishInfo(c2).urgent = True
        with mock.patch('zeit.workflow.publish.PublishTask'
                        '.call_publish_script') as script:
            IPublish(self.repository).publish_multiple([c1, c2], async=False)
            script.assert_called_with([
                'work/online/2007/01/Somalia',
                'work/online/2007/01/eta-zapatero'
            ])
        self.assertTrue(IPublishInfo(c1).published)
        self.assertTrue(IPublishInfo(c2).published)

        with mock.patch('zeit.workflow.publish.RetractTask'
                        '.call_retract_script') as script:
            IPublish(self.repository).retract_multiple([c1, c2], async=False)
            script.assert_called_with([
                'work/online/2007/01/Somalia',
                'work/online/2007/01/eta-zapatero'
            ])
        self.assertFalse(IPublishInfo(c1).published)
        self.assertFalse(IPublishInfo(c2).published)
Exemple #2
0
 def test_update_should_trigger_highlight_tags_call(self):
     with mock.patch(
             'zeit.cms.tagging.browser.widget.UpdateTags.json') as mocked:
         self.open_content()
         s = self.selenium
         s.click('update_tags')
         s.pause(100)
         self.assertTrue(mocked.called)
 def test_inconsistent_child_names_do_not_yields_non_existing_objects(self):
     self.repository['cache'] = zeit.cms.repository.folder.Folder()
     folder = self.repository['cache']
     folder['one'] = ExampleContentType()
     with mock.patch('zeit.connector.mock.Connector.listCollection') as lst:
         lst.return_value = [('one', 'http://xml.zeit.de/cache/one'),
                             ('two', 'http://xml.zeit.de/cache/two')]
         self.assertEquals(['one', 'two'], list(folder.keys()))
         self.assertEquals(['http://xml.zeit.de/cache/one'],
                           [x.uniqueId for x in folder.values()])
Exemple #4
0
 def test_accepts_uniqueId_as_well_as_ICMSContent(self):
     with mock.patch('zeit.workflow.publish.MultiPublishTask.run') as run:
         IPublish(self.repository).publish_multiple([
             self.repository['testcontent'],
             'http://xml.zeit.de/online/2007/01/Somalia'
         ],
                                                    async=False)
         ids = run.call_args[0][0]
         self.assertEqual([
             'http://xml.zeit.de/testcontent',
             'http://xml.zeit.de/online/2007/01/Somalia'
         ], ids)
Exemple #5
0
 def test_determines_priority_via_adapter(self):
     content = self.repository['testcontent']
     info = IPublishInfo(content)
     info.urgent = True
     self.assertFalse(info.published)
     with mock.patch(
             'zeit.cms.workflow.interfaces.IPublishPriority') as priority,\
             mock.patch.object(zeit.workflow.publish.PUBLISH_TASK,
                               'apply_async') as apply_async:
         priority.return_value = zeit.cms.workflow.interfaces.PRIORITY_LOW
         IPublish(content).publish()
     apply_async.assert_called_with(([u'http://xml.zeit.de/testcontent'], ),
                                    queuename='publish_lowprio')
Exemple #6
0
    def test_updater_suppress_errors(self):
        content = ICheckoutManager(self.repository['testcontent']).checkout()
        content.authorships = (content.authorships.create(self.shakespeare), )

        # This error condition cannot be synthesized easily (would need to make
        # an Author lose its metadata so it's treated as
        # PersistentUnknownResource).

        with mock.patch('zeit.content.author.author.Author.display_name',
                        gocept.testing.mock.Property()) as display_name:
            display_name.side_effect = AttributeError()
            with self.assertNothingRaised():
                updater = zeit.cms.content.interfaces.IXMLReferenceUpdater(
                    content)
                updater.update(content.xml, suppress_errors=True)
    def test_updater_suppress_errors(self):
        content = ICheckoutManager(self.repository['testcontent']).checkout()
        content.authorships = (content.authorships.create(self.shakespeare),)

        # This error condition cannot be synthesized easily (would need to make
        # an Author lose its metadata so it's treated as
        # PersistentUnknownResource).

        with mock.patch('zeit.content.author.author.Author.display_name',
                        gocept.testing.mock.Property()) as display_name:
            display_name.side_effect = AttributeError()
            with self.assertNothingRaised():
                updater = zeit.cms.content.interfaces.IXMLReferenceUpdater(
                    content)
                updater.update(content.xml, suppress_errors=True)
Exemple #8
0
 def test_empty_list_of_objects_does_not_run_publish(self):
     with mock.patch('zeit.workflow.publish.PublishTask'
                     '.call_publish_script') as script:
         IPublish(self.repository).publish_multiple([], async=False)
         self.assertFalse(script.called)