def test_send_sms_reply_success(self): mocked_message_id = TransportMessage.generate_id() reply_to_msgid = TransportMessage.generate_id() mocked_message = "Result_code: 00, Message OK" # open an HTTP resource that mocks the Vas2Nets response for the # duration of this test yield self.make_resource_worker(mocked_message_id, mocked_message, send_id=reply_to_msgid) yield self.dispatch(self.mkmsg_out(in_reply_to=reply_to_msgid)) [smsg] = self.get_dispatched('vas2nets.event') self.assertEqual(self.mkmsg_ack(sent_message_id=mocked_message_id), TransportMessage.from_json(smsg.body))
def test_send_sms_reply_success(self): mocked_message_id = TransportMessage.generate_id() reply_to_msgid = TransportMessage.generate_id() mocked_message = "Result_code: 00, Message OK" # open an HTTP resource that mocks the Vas2Nets response for the # duration of this test yield self.start_mock_server(mocked_message_id, mocked_message, send_id=reply_to_msgid) sent_msg = yield self.make_dispatch_outbound( "hello", in_reply_to=reply_to_msgid) msg = self.tx_helper.make_ack( sent_msg, sent_message_id=mocked_message_id) [ack] = self.tx_helper.get_dispatched_events() self.assert_events_equal(msg, ack)
def make_request(self, path, qparams): """ Builds a request URL with the appropriate params. """ args = { 'messageid': TransportMessage.generate_id(), 'time': self.today.strftime('%Y.%m.%d %H:%M:%S'), 'sender': '0041791234567', 'destination': '9292', 'provider': 'provider', 'keyword': '', 'header': '', 'text': '', 'keyword': '', } args.update(qparams) url = self.transport_url + path return http_request_full(url, urlencode(args), { 'Content-Type': ['application/x-www-form-urlencoded'], })