Skip to content

Commit

Permalink
Merge pull request rapidpro#210 from praekelt/develop
Browse files Browse the repository at this point in the history
Update docker production branch
  • Loading branch information
KaitCrawford authored Oct 31, 2017
2 parents 2c9cfc3 + 976066a commit 8bb2694
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion casepro/backend/junebug.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def build_outgoing_message_json(self, outgoing, to_addr):
reply_to = outgoing.reply_to.text
label = ','.join([str(l) for l in outgoing.reply_to.labels.all()])
inbound_created_on = outgoing.reply_to.created_on
inbound_channel_id = outgoing.reply_to.metadata.get('channel_id', "")
inbound_channel_id = outgoing.reply_to.metadata.get('channel_id')
if not inbound_channel_id:
inbound_channel_id = ""

return {
'to': to_addr,
Expand Down
10 changes: 6 additions & 4 deletions casepro/backend/tests/test_junebug.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ def hub_outgoing_callback(request):
self.assertEqual(data, {
'content': "That's great", 'inbound_created_on': '2016-11-17T10:30:00+00:00',
'outbound_created_on': '2016-11-17T10:30:00+00:00',
'label': '', 'reply_to': '', 'to': '+1234', 'user_id': 'C-002', 'helpdesk_operator_id': self.user1.id,
'label': '', 'reply_to': 'Hello', 'to': '+1234', 'user_id': 'C-002',
'helpdesk_operator_id': self.user1.id,
'inbound_channel_id': ''})
headers = {'Content-Type': "application/json"}
resp = {
Expand All @@ -767,12 +768,13 @@ def hub_outgoing_callback(request):
self.add_hub_outgoing_callback(hub_outgoing_callback)

bob = self.create_contact(self.unicef, "C-002", "Bob")

# for messages created manually, there is not "reply-to"
msg = self.create_message(
self.unicef, 123, bob, "Hello", created_on=datetime(2016, 11, 17, 10, 30, tzinfo=pytz.utc),
metadata={"channel_id": None})
self.backend = JunebugBackend()
out_msg = self.create_outgoing(
self.unicef, self.user1, None, "B", "That's great", bob, urn="tel:+1234",
created_on=datetime(2016, 11, 17, 10, 30, tzinfo=pytz.utc))
reply_to=msg, created_on=datetime(2016, 11, 17, 10, 30, tzinfo=pytz.utc))

with mock.patch('casepro.backend.junebug.logger.error') as mock_logger:
self.backend.push_outgoing(self.unicef, [out_msg])
Expand Down

0 comments on commit 8bb2694

Please sign in to comment.