Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import asyncio
  2. from datetime import datetime, timedelta
  3. from unittest.mock import patch
  4.  
  5. from bson import ObjectId
  6. from freezegun import freeze_time
  7.  
  8. import settings
  9.  
  10.  
  11. async def test_coro():
  12.     return None
  13.  
  14.  
  15. class TestSmsAPI:
  16.     @classmethod
  17.     def setup_class(cls):
  18.  
  19.         f = asyncio.Future()
  20.         f.set_result(None)
  21.  
  22.         cls.patcher = patch('send', return_value=test_coro())
  23.         cls.mock = cls.patcher.start()
  24.  
  25.     async def test_sms_sending(self, http_client):
  26.         data = {
  27.             'recipient': '+40746697852',
  28.             'content': 'Some message'
  29.         }
  30.  
  31.         resp = await http_client.post('/sms', json=data, headers={settings.AUTH_HEADER: f'Key {self.client.key}'})
  32.  
  33.         data = await resp.json()
  34.  
  35.         self.mock.assert_called_with(to='0040746697852', content='Some message')
  36.  
  37.         assert resp.status == 201
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement