Skip to content

Commit

Permalink
Fix validation code verification passing login_method as a string ins…
Browse files Browse the repository at this point in the history
…tead of a var
  • Loading branch information
bdraco committed Mar 11, 2020
1 parent 3556550 commit adc6718
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion august/api_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _build_validate_verification_code_request(
"method": "post",
"url": API_VALIDATE_VERIFICATION_CODE_URLS[login_method],
"access_token": access_token,
"json": {"login_method": username, "code": str(verification_code)},
"json": {login_method: username, "code": str(verification_code)},
}

def _build_get_doorbells_request(self, access_token):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="py-august",
version="0.24.0",
version="0.25.0",
packages=["august"],
url="https://github.com/snjoetw/py-august",
license="MIT",
Expand Down
21 changes: 20 additions & 1 deletion tests/test_api_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

from aiohttp import ClientError, ClientResponse, ClientSession
from aiohttp.helpers import TimerNoop
from aioresponses import aioresponses
from aioresponses import aioresponses, CallbackResult
import aiounittest
from asynctest import mock
import august.activity
from august.api_async import ApiAsync, _raise_response_exceptions
from august.api_common import (
API_VALIDATE_VERIFICATION_CODE_URLS,
API_GET_DOORBELL_URL,
API_GET_DOORBELLS_URL,
API_GET_HOUSE_ACTIVITIES_URL,
Expand Down Expand Up @@ -698,6 +699,24 @@ async def test_async_get_house_activities(self, mock):
self.assertIsInstance(activities[8], august.activity.LockOperationActivity)
self.assertIsInstance(activities[9], august.activity.LockOperationActivity)

@aioresponses()
async def test_async_validate_verification_code(self, mock):
last_args = {}

def response_callback(url, **kwargs):
last_args.update(kwargs)
return CallbackResult(status=200, body="{}")

mock.post(
API_VALIDATE_VERIFICATION_CODE_URLS["email"], callback=response_callback
)

api = ApiAsync(ClientSession())
await api.async_validate_verification_code(
ACCESS_TOKEN, "email", "emailaddress", 123456
)
assert last_args["json"] == {"code": "123456", "email": "emailaddress"}

def test__raise_response_exceptions(self):
loop = mock.Mock()
request_info = mock.Mock()
Expand Down

0 comments on commit adc6718

Please sign in to comment.