def test_properties_can_be_set_while_checked_out(self): content = ICMSContent('http://xml.zeit.de/testcontent') with checked_out(content) as co: push = IPushMessages(co) push.message_config = [{'type': 'mypush'}] content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) self.assertEqual([{'type': 'mypush'}], push.message_config) # These DAV properties are not serialized to XML. self.assertNotIn('mypush', zeit.cms.testing.xmltotext(content.xml))
def test_error_during_push_is_caught(self): self.notifier.send.side_effect = RuntimeError('provoked') content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) push.message_config = [{'type': 'mypush', 'enabled': True}] self.publish(content) # This is sort of assertNothingRaised, except that publishing # runs in a separate thread (remotetask), so we would not see # the exception here anyway. self.assertNotEqual(None, push.date_last_pushed)
def test_error_during_push_is_caught(self): self.notifier.send.side_effect = RuntimeError('provoked') content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) push.message_config = [{'type': 'mypush', 'enabled': True}] self.publish(content) # This is sort of assertNothingRaised, except that publishing # runs in a separate thread (remotetask), so we would not see # the exception here anyway. log = list(zeit.objectlog.interfaces.ILog(content).get_log()) self.assertStartsWith('Error while sending', log[-1].message)
def test_publish_triggers_push_notification_via_message_config(self): from zeit.push.interfaces import IPushMessages push = IPushMessages(self.content) push.message_config = [{'type': 'mobile', 'enabled': True}] self.publish(self.content) calls = zope.component.getUtility(zeit.push.interfaces.IPushNotifier, name='urbanairship').calls self.assertEqual(calls[0][0], 'content_title') self.assertEqual(calls[0][1], u'http://www.zeit.de/content') self.assertEqual(calls[0][2].get('enabled'), True) self.assertEqual(calls[0][2].get('type'), 'mobile')
def test_updates_last_push_date(self): content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) self.assertEqual(None, push.date_last_pushed) self.publish(content) self.assertNotEqual(None, push.date_last_pushed)
def test_disabled_service_is_not_called(self): content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) push.message_config = [{'type': 'mypush', 'enabled': False}] self.publish(content) self.assertFalse(self.notifier.send.called)
def test_properties_can_be_set_while_checked_in(self): content = ICMSContent('http://xml.zeit.de/testcontent') push = IPushMessages(content) push.message_config = [{'type': 'mypush'}] self.assertEqual([{'type': 'mypush'}], push.message_config)