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

Commit

Permalink
Added test for sending to an opted out user when optout checking is d…
Browse files Browse the repository at this point in the history
…isabled for account
  • Loading branch information
Rudi Giesler committed Jan 21, 2015
1 parent e516d23 commit 04a46f8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions go/apps/http_api_nostream/tests/test_vumi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,37 @@ def test_send_to_opted_out(self):
self.assertEqual(put_msg['success'], False)
self.assertEqual(put_msg['reason'], 'Recipient has opted out')

@inlineCallbacks
def test_send_to_opted_out_optouts_disabled(self):
yield self.start_app_worker()
# Create optout for user
vumi_api = self.app_helper.vumi_helper.get_vumi_api()
user_api = vumi_api.get_user_api(self.conversation.user_account.key)
optout_store = user_api.optout_store
optout_store.new_opt_out('msisdn', '+5432', {'message_id': '111'})
msg = {
'to_addr': '+5432',
'content': 'foo',
'message_id': 'evil_id',
}

# Disable optouts
user_account = yield user_api.get_user_account()
user_account.disable_optouts = True
yield user_account.save()

url = '%s/%s/messages.json' % (self.url, self.conversation.key)
response = yield http_request_full(url, json.dumps(msg),
self.auth_headers, method='PUT')

self.assertEqual(response.code, http.OK)
self.assertEqual(
response.headers.getRawHeaders('content-type'),
['application/json; charset=utf-8'])
put_msg = json.loads(response.delivered_body)
self.assertEqual(put_msg['to_addr'], msg['to_addr'])
self.assertEqual(put_msg['content'], msg['content'])

@inlineCallbacks
def test_in_reply_to(self):
yield self.start_app_worker()
Expand Down

0 comments on commit 04a46f8

Please sign in to comment.