This commit is contained in:
Paulus Schoutsen 2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View file

@ -3,14 +3,24 @@ from homeassistant.components.alexa.auth import Auth
from . import TEST_TOKEN_URL
async def run_auth_get_access_token(hass, aioclient_mock, expires_in,
client_id, client_secret,
accept_grant_code, refresh_token):
async def run_auth_get_access_token(
hass,
aioclient_mock,
expires_in,
client_id,
client_secret,
accept_grant_code,
refresh_token,
):
"""Do auth and request a new token for tests."""
aioclient_mock.post(TEST_TOKEN_URL,
json={'access_token': 'the_access_token',
'refresh_token': refresh_token,
'expires_in': expires_in})
aioclient_mock.post(
TEST_TOKEN_URL,
json={
"access_token": "the_access_token",
"refresh_token": refresh_token,
"expires_in": expires_in,
},
)
auth = Auth(hass, client_id, client_secret)
await auth.async_do_auth(accept_grant_code)
@ -24,9 +34,15 @@ async def test_auth_get_access_token_expired(hass, aioclient_mock):
accept_grant_code = "abcdefg"
refresh_token = "refresher"
await run_auth_get_access_token(hass, aioclient_mock, -5,
client_id, client_secret,
accept_grant_code, refresh_token)
await run_auth_get_access_token(
hass,
aioclient_mock,
-5,
client_id,
client_secret,
accept_grant_code,
refresh_token,
)
assert len(aioclient_mock.mock_calls) == 2
calls = aioclient_mock.mock_calls
@ -52,9 +68,15 @@ async def test_auth_get_access_token_not_expired(hass, aioclient_mock):
accept_grant_code = "abcdefg"
refresh_token = "refresher"
await run_auth_get_access_token(hass, aioclient_mock, 555,
client_id, client_secret,
accept_grant_code, refresh_token)
await run_auth_get_access_token(
hass,
aioclient_mock,
555,
client_id,
client_secret,
accept_grant_code,
refresh_token,
)
assert len(aioclient_mock.mock_calls) == 1
call = aioclient_mock.mock_calls