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

Commit

Permalink
Display failure reason.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Apr 30, 2015
1 parent c954377 commit 98e7205
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
20 changes: 10 additions & 10 deletions go/conversation/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,21 +846,21 @@ def test_message_list_outbound_status_pending(self):
r_out = self.client.get(
self.get_view_url(conv, 'message_list'),
{'direction': 'outbound'})
self.assertContains(r_out, "<td>pending</td>", html=True)
self.assertNotContains(r_out, "<td>sent</td>", html=True)
self.assertNotContains(r_out, "<td>failed</td>", html=True)
self.assertContains(r_out, "<td>pending", html=True)
self.assertNotContains(r_out, "<td>sent", html=True)
self.assertNotContains(r_out, "<td>failed", html=True)

def test_message_list_outbound_status_failed(self):
conv = self.user_helper.create_conversation(u'dummy', started=True)
msg = self.msg_helper.make_stored_outbound(conv, "hi")
self.msg_helper.make_stored_nack(conv, msg)
self.msg_helper.make_stored_nack(conv, msg, nack_reason="no spoons")

r_out = self.client.get(
self.get_view_url(conv, 'message_list'),
{'direction': 'outbound'})
self.assertContains(r_out, "<td>failed</td>", html=True)
self.assertNotContains(r_out, "<td>pending</td>", html=True)
self.assertNotContains(r_out, "<td>sent</td>", html=True)
self.assertContains(r_out, "<td>failed: no spoons", html=True)
self.assertNotContains(r_out, "<td>pending", html=True)
self.assertNotContains(r_out, "<td>sent", html=True)

def test_message_list_outbound_status_sent(self):
conv = self.user_helper.create_conversation(u'dummy', started=True)
Expand All @@ -870,9 +870,9 @@ def test_message_list_outbound_status_sent(self):
r_out = self.client.get(
self.get_view_url(conv, 'message_list'),
{'direction': 'outbound'})
self.assertContains(r_out, "<td>sent</td>", html=True)
self.assertNotContains(r_out, "<td>pending</td>", html=True)
self.assertNotContains(r_out, "<td>failed</td>", html=True)
self.assertContains(r_out, "<td>sent", html=True)
self.assertNotContains(r_out, "<td>pending", html=True)
self.assertNotContains(r_out, "<td>failed", html=True)

def test_message_list_with_bad_transport_type_inbound(self):
# inbound messages could have an unsupported transport_type
Expand Down
16 changes: 9 additions & 7 deletions go/conversation/view_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ def get(self, request, conversation):
batch_id = conversation.batch.key

def add_event_status(msg):
msg.event_status = u"pending"
get_event_info = conversation.mdb.message_event_keys_with_statuses
types = [e[2] for e in get_event_info(msg["message_id"])]
if u"ack" in types:
msg.event_status = u"sent"
elif u"nack" in types:
msg.event_status = u"failed"
else:
msg.event_status = u"pending"
for event_id, _, event_type in get_event_info(msg["message_id"]):
if event_type == u"ack":
msg.event_status = u"sent"
break
if event_type == u"nack":
event = conversation.mdb.get_event(event_id)
msg.event_status = u"failed: %s" % (event["nack_reason"],)
break
return msg

def get_sent_messages(start, stop):
Expand Down

0 comments on commit 98e7205

Please sign in to comment.