def load_event(self, channel_id, message_id, event_id): '''Loads the event with id event_id''' key = self.get_key(channel_id, message_id) event_json = yield self.load_property(key, event_id) if event_json is None: returnValue(None) returnValue(TransportEvent.from_json(event_json))
def load_all_events(self, channel_id, message_id): '''Returns a list of all the stored events''' key = self.get_key(channel_id, message_id) events_json = yield self.load_all(key) self._remove_property_keys(events_json) returnValue([ TransportEvent.from_json(e) for e in events_json.values()])
def load_event(self, channel_id, message_id, event_id): '''Loads the event with id event_id''' key = self.get_key(channel_id, message_id) event_json = yield self.load_property(key, event_id) if event_json is None: returnValue(None) returnValue(TransportEvent.from_json(event_json))
def test_post_delivery_report(self): yield self.start_app_worker() msg1 = yield self.make_outbound( self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_delivery_report( msg1, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() self.assertEqual( req.requestHeaders.getRawHeaders('content-type'), ['application/json; charset=utf-8']) req.finish() dr1 = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), dr1)
def test_post_inbound_event(self): msg1 = yield self.app_helper.make_stored_outbound( self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_ack( msg1, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() self.assertEqual( req.requestHeaders.getRawHeaders('content-type'), ['application/json; charset=utf-8']) req.finish() ack1 = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), ack1)
def test_post_inbound_event(self): msg1 = yield self.app_helper.make_stored_outbound(self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_ack(msg1, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() self.assertEqual(req.requestHeaders.getRawHeaders('content-type'), ['application/json; charset=utf-8']) req.finish() ack1 = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), ack1)
def test_post_unknown_event(self): yield self.start_app_worker() # temporarily pretend the worker doesn't know about acks del self.app._event_handlers['ack'] msg1 = yield self.make_outbound( self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_ack( msg1, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() self.assertEqual( req.requestHeaders.getRawHeaders('content-type'), ['application/json; charset=utf-8']) req.finish() ack1 = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), ack1)
def test_post_inbound_event(self): # Set the URL so stuff is HTTP Posted instead of streamed. self.conversation.config['http_api'].update({ 'push_event_url': self.mock_push_server.url, }) yield self.conversation.save() msg = yield self.app_helper.make_stored_outbound( self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_ack( msg, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() req.finish() ack = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), ack)
def test_post_inbound_event(self): # Set the URL so stuff is HTTP Posted instead of streamed. self.conversation.config['http_api'].update({ 'push_event_url': self.mock_push_server.url, }) yield self.conversation.save() msg = yield self.app_helper.make_stored_outbound(self.conversation, 'out 1', message_id='1') event_d = self.app_helper.make_dispatch_ack(msg, conv=self.conversation) req = yield self.push_calls.get() posted_json_data = req.content.read() req.finish() ack = yield event_d self.assertEqual(TransportEvent.from_json(posted_json_data), ack)
def cb(request): events.append(TransportEvent.from_json(request.content.getvalue())) return ''
def cb(request): events.append(TransportEvent.from_json(request.content.getvalue())) return ''