Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
including endpoints in export + test
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Feb 10, 2014
1 parent d7bd61c commit 7d5ddbd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/conversation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'network_handover_status',
'network_handover_reason',
'delivery_status',
'endpoint',
]


Expand All @@ -46,6 +47,7 @@ def row_for_inbound_message(message):
for field in conversation_export_field_names
if field in message)
row['direction'] = 'inbound'
row['endpoint'] = message.get_routing_endpoint()
return row


Expand All @@ -65,6 +67,7 @@ def row_for_outbound_message(message, mdb):
status, reason = get_network_status(network_events)
row['network_handover_status'] = status
row['network_handover_reason'] = reason
row['endpoint'] = message.get_routing_endpoint()
return row


Expand Down
24 changes: 24 additions & 0 deletions go/conversation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,3 +990,27 @@ def test_export_conversation_nack(self):
[row] = list(reader)
self.assertEqual(row['network_handover_status'], 'nack')
self.assertEqual(row['network_handover_reason'], 'foo')

def test_export_conversation_endpoints(self):
conv = self.create_conversation(reply_count=0)

msg = self.msg_helper.make_outbound(
"outbound", conv=conv, to_addr='from-1')
msg.set_routing_endpoint('foo')
self.msg_helper.store_outbound(conv, msg)

msg = self.msg_helper.make_outbound(
"inbound", conv=conv, from_addr='from-1')
msg.set_routing_endpoint('bar')
self.msg_helper.store_inbound(conv, msg)

export_conversation_messages_unsorted(conv.user_account.key, conv.key)
[email] = mail.outbox
fp = self.get_zipfile_attachment(
email, 'messages-export.zip', 'messages-export.csv')
reader = csv.DictReader(fp)
[row1, row2] = list(reader)
self.assertEqual(row1['direction'], 'inbound')
self.assertEqual(row1['endpoint'], 'bar')
self.assertEqual(row2['direction'], 'outbound')
self.assertEqual(row2['endpoint'], 'foo')

0 comments on commit 7d5ddbd

Please sign in to comment.