Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.

Commit

Permalink
Add tests for inbound message statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudi Giesler committed Feb 19, 2016
1 parent dd239a5 commit 5f5b106
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions vxyowsup/tests/test_whatsapp.py
Expand Up @@ -64,6 +64,7 @@ def setUp(self):
'cc': '27',
'phone': '27010203040',
'password': base64.b64encode("xxx"),
'publish_status': True,
}

self.transport = yield self.tx_helper.get_transport(self.config)
Expand Down Expand Up @@ -200,6 +201,33 @@ def test_non_ascii_publish(self):
PTNode_to_TUMessage(message_sent, '+27010203040'),
message_received)

@inlineCallbacks
def test_cannot_decode_message(self):
'''When the inbound message cannot be decoded, we should send a
degraded status message.'''
yield self.testing_layer.send_to_transport(
text=u'Hi Vumi! :)'.encode('utf-16'),
from_address='123345@s.whatsapp.net')
[status] = yield self.tx_helper.wait_for_dispatched_statuses(1)
self.assertEqual(status['status'], 'degraded')
self.assertEqual(status['component'], 'inbound')
self.assertEqual(status['type'], 'inbound_error')
self.assertEqual(status['message'], 'Cannot decode')

@inlineCallbacks
def test_status_message_for_inbound_message(self):
'''If we are successfully able to decode the inbound message, we should
send a successful status message.'''
yield self.testing_layer.send_to_transport(
text='Hi Vumi! :)',
from_address='123345@s.whatsapp.net')
[status] = yield self.tx_helper.wait_for_dispatched_statuses(1)
self.assertEqual(status['status'], 'ok')
self.assertEqual(status['component'], 'inbound')
self.assertEqual(status['type'], 'inbound_success')
self.assertEqual(
status['message'], 'Inbound message successfully processed')


def dummy_getLayerInterface(parent_interface, layer_cls):
if layer_cls.__name__ == 'YowNetworkLayer':
Expand Down

0 comments on commit 5f5b106

Please sign in to comment.