|
3 | 3 |
|
4 | 4 | from aiohttp import ClientError, ClientResponse, ClientSession
|
5 | 5 | from aiohttp.helpers import TimerNoop
|
6 |
| -from aioresponses import aioresponses |
| 6 | +from aioresponses import aioresponses, CallbackResult |
7 | 7 | import aiounittest
|
8 | 8 | from asynctest import mock
|
9 | 9 | import august.activity
|
10 | 10 | from august.api_async import ApiAsync, _raise_response_exceptions
|
11 | 11 | from august.api_common import (
|
| 12 | + API_VALIDATE_VERIFICATION_CODE_URLS, |
12 | 13 | API_GET_DOORBELL_URL,
|
13 | 14 | API_GET_DOORBELLS_URL,
|
14 | 15 | API_GET_HOUSE_ACTIVITIES_URL,
|
@@ -698,6 +699,24 @@ async def test_async_get_house_activities(self, mock):
|
698 | 699 | self.assertIsInstance(activities[8], august.activity.LockOperationActivity)
|
699 | 700 | self.assertIsInstance(activities[9], august.activity.LockOperationActivity)
|
700 | 701 |
|
| 702 | + @aioresponses() |
| 703 | + async def test_async_validate_verification_code(self, mock): |
| 704 | + last_args = {} |
| 705 | + |
| 706 | + def response_callback(url, **kwargs): |
| 707 | + last_args.update(kwargs) |
| 708 | + return CallbackResult(status=200, body="{}") |
| 709 | + |
| 710 | + mock.post( |
| 711 | + API_VALIDATE_VERIFICATION_CODE_URLS["email"], callback=response_callback |
| 712 | + ) |
| 713 | + |
| 714 | + api = ApiAsync(ClientSession()) |
| 715 | + await api.async_validate_verification_code( |
| 716 | + ACCESS_TOKEN, "email", "emailaddress", 123456 |
| 717 | + ) |
| 718 | + assert last_args["json"] == {"code": "123456", "email": "emailaddress"} |
| 719 | + |
701 | 720 | def test__raise_response_exceptions(self):
|
702 | 721 | loop = mock.Mock()
|
703 | 722 | request_info = mock.Mock()
|
|
0 commit comments