def test_omit(self): coll = { 'foo': 'bar', 'baz': 'quux', 'corge': 'grault', 'garply': 'waldo', } self.assertEqual(omit(coll, 'foo', 'garply'), { 'baz': 'quux', 'corge': 'grault', }) self.assertEqual(coll, { 'foo': 'bar', 'baz': 'quux', 'corge': 'grault', 'garply': 'waldo', })
def test_send_message_reply(self): '''Sending a reply message should fetch the relevant inbound message, use it to construct a reply message, and place the reply message on the queue for the channel''' channel = Channel( redis_manager=(yield self.get_redis()), config=(yield self.create_channel_config()), properties=self.create_channel_properties(), id='test-channel') yield channel.save() yield channel.start(self.service) in_msg = TransportUserMessage( from_addr='+2789', to_addr='+1234', transport_name='test-channel', transport_type='_', transport_metadata={'foo': 'bar'}) yield self.api.inbounds.store_vumi_message('test-channel', in_msg) expected = in_msg.reply(content='testcontent') expected = api_from_message(expected) resp = yield self.post('/channels/test-channel/messages/', { 'reply_to': in_msg['message_id'], 'content': 'testcontent', }) yield self.assert_response( resp, http.OK, 'message sent', omit(expected, 'timestamp', 'message_id'), ignore=['timestamp', 'message_id']) [message] = self.get_dispatched_messages('test-channel.outbound') message_id = (yield resp.json())['result']['message_id'] self.assertEqual(message['message_id'], message_id)
def test_send_message_reply(self): '''Sending a reply message should fetch the relevant inbound message, use it to construct a reply message, and place the reply message on the queue for the channel''' channel = Channel(redis_manager=(yield self.get_redis()), config=(yield self.create_channel_config()), properties=self.create_channel_properties(), id='test-channel') yield channel.save() yield channel.start(self.service) in_msg = TransportUserMessage(from_addr='+2789', to_addr='+1234', transport_name='test-channel', transport_type='_', transport_metadata={'foo': 'bar'}) yield self.api.inbounds.store_vumi_message('test-channel', in_msg) expected = in_msg.reply(content='testcontent') expected = api_from_message(expected) resp = yield self.post('/channels/test-channel/messages/', { 'reply_to': in_msg['message_id'], 'content': 'testcontent', }) yield self.assert_response(resp, http.OK, 'message sent', omit(expected, 'timestamp', 'message_id'), ignore=['timestamp', 'message_id']) [message] = self.get_dispatched_messages('test-channel.outbound') message_id = (yield resp.json())['result']['message_id'] self.assertEqual(message['message_id'], message_id)