Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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)