Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- from datetime import datetime, timedelta
- from unittest.mock import patch
- from bson import ObjectId
- from freezegun import freeze_time
- import settings
- async def test_coro():
- return None
- class TestSmsAPI:
- @classmethod
- def setup_class(cls):
- f = asyncio.Future()
- f.set_result(None)
- cls.patcher = patch('send', return_value=test_coro())
- cls.mock = cls.patcher.start()
- async def test_sms_sending(self, http_client):
- data = {
- 'recipient': '+40746697852',
- 'content': 'Some message'
- }
- resp = await http_client.post('/sms', json=data, headers={settings.AUTH_HEADER: f'Key {self.client.key}'})
- data = await resp.json()
- self.mock.assert_called_with(to='0040746697852', content='Some message')
- assert resp.status == 201
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement