Last active
December 14, 2015 08:09
-
-
Save jerith/5055881 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/go/apps/bulk_message/tests/test_vumi_app.py b/go/apps/bulk_message/tests/test_vum | |
| index 6a071cd..1f728c3 100644 | |
| --- a/go/apps/bulk_message/tests/test_vumi_app.py | |
| +++ b/go/apps/bulk_message/tests/test_vumi_app.py | |
| @@ -214,6 +214,37 @@ class TestBulkMessageApplication(AppWorkerTestCase): | |
| self.assertEqual(sent_msg['in_reply_to'], msg['message_id']) | |
| @inlineCallbacks | |
| + def test_process_command_send_message_in_reply_to_bad_transport_name(self): | |
| + msg = self.mkmsg_in(message_id=uuid.uuid4().hex, transport_name="bad") | |
| + yield self.vumi_api.mdb.add_inbound_message(msg) | |
| + command = VumiApiCommand.command('worker', 'send_message', | |
| + command_data={ | |
| + u'batch_id': u'batch-id', | |
| + u'content': u'foo', | |
| + u'to_addr': u'to_addr', | |
| + u'msg_options': { | |
| + u'helper_metadata': { | |
| + u'go': { | |
| + u'user_account': u'account-key' | |
| + }, | |
| + u'tag': { | |
| + u'tag': [u'longcode', u'default10080'] | |
| + } | |
| + }, | |
| + u'transport_name': u'smpp_transport', | |
| + u'in_reply_to': msg['message_id'], | |
| + u'transport_type': u'sms', | |
| + u'from_addr': u'default10080', | |
| + } | |
| + }) | |
| + yield self.app.consume_control_command(command) | |
| + [sent_msg] = self.get_dispatched_messages() | |
| + self.assertEqual(sent_msg['to_addr'], msg['from_addr']) | |
| + self.assertEqual(sent_msg['content'], 'foo') | |
| + self.assertEqual(sent_msg['in_reply_to'], msg['message_id']) | |
| + self.assertEqual(sent_msg['transport_name'], 'smpp_transport') | |
| + | |
| + @inlineCallbacks | |
| def test_collect_metrics(self): | |
| conv = yield self.create_conversation( | |
| delivery_tag_pool=u'pool', delivery_class=u'sms') | |
| diff --git a/go/apps/bulk_message/vumi_app.py b/go/apps/bulk_message/vumi_app.py | |
| index c358bfe..ea04a79 100644 | |
| --- a/go/apps/bulk_message/vumi_app.py | |
| +++ b/go/apps/bulk_message/vumi_app.py | |
| @@ -134,6 +134,9 @@ class BulkMessageApplication(GoApplicationWorker): | |
| if in_reply_to: | |
| msg = yield self.vumi_api.mdb.get_inbound_message(in_reply_to) | |
| if msg: | |
| + # We can't override transport_name in reply_to(), so we set it | |
| + # on the message we're replying to. | |
| + msg['transport_name'] = msg_options['transport_name'] | |
| yield self.reply_to(msg, content) | |
| else: | |
| log.warning('Unable to reply, message %s does not exist.' % ( | |
| diff --git a/go/apps/surveys/tests/test_vumi_app.py b/go/apps/surveys/tests/test_vumi_app.py | |
| index ef9b7f6..777e843 100644 | |
| --- a/go/apps/surveys/tests/test_vumi_app.py | |
| +++ b/go/apps/surveys/tests/test_vumi_app.py | |
| @@ -335,3 +335,34 @@ class TestSurveyApplication(AppWorkerTestCase): | |
| self.assertEqual(sent_msg['to_addr'], msg['from_addr']) | |
| self.assertEqual(sent_msg['content'], 'foo') | |
| self.assertEqual(sent_msg['in_reply_to'], msg['message_id']) | |
| + | |
| + @inlineCallbacks | |
| + def test_process_command_send_message_in_reply_to_bad_transport_name(self): | |
| + msg = self.mkmsg_in(message_id=uuid.uuid4().hex, transport_name="bad") | |
| + yield self.vumi_api.mdb.add_inbound_message(msg) | |
| + command = VumiApiCommand.command('worker', 'send_message', | |
| + command_data={ | |
| + u'batch_id': u'batch-id', | |
| + u'content': u'foo', | |
| + u'to_addr': u'to_addr', | |
| + u'msg_options': { | |
| + u'helper_metadata': { | |
| + u'go': { | |
| + u'user_account': u'account-key' | |
| + }, | |
| + u'tag': { | |
| + u'tag': [u'longcode', u'default10080'] | |
| + } | |
| + }, | |
| + u'transport_name': u'smpp_transport', | |
| + u'in_reply_to': msg['message_id'], | |
| + u'transport_type': u'sms', | |
| + u'from_addr': u'default10080', | |
| + } | |
| + }) | |
| + yield self.app.consume_control_command(command) | |
| + [sent_msg] = self.get_dispatched_messages() | |
| + self.assertEqual(sent_msg['to_addr'], msg['from_addr']) | |
| + self.assertEqual(sent_msg['content'], 'foo') | |
| + self.assertEqual(sent_msg['in_reply_to'], msg['message_id']) | |
| + self.assertEqual(sent_msg['transport_name'], 'smpp_transport') | |
| diff --git a/go/apps/surveys/vumi_app.py b/go/apps/surveys/vumi_app.py | |
| index c9647a2..d6a7e7c 100644 | |
| --- a/go/apps/surveys/vumi_app.py | |
| +++ b/go/apps/surveys/vumi_app.py | |
| @@ -169,6 +169,9 @@ class SurveyApplication(PollApplication, GoApplicationMixin): | |
| if in_reply_to: | |
| msg = yield self.vumi_api.mdb.get_inbound_message(in_reply_to) | |
| if msg: | |
| + # We can't override transport_name in reply_to(), so we set it | |
| + # on the message we're replying to. | |
| + msg['transport_name'] = msg_options['transport_name'] | |
| yield self.reply_to(msg, content) | |
| else: | |
| log.warning('Unable to reply, message %s does not exist.' % ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍