Add type hints to core tests (part 2) (#88492)
This commit is contained in:
parent
a102883eff
commit
a51cc75f03
17 changed files with 383 additions and 216 deletions
|
@ -41,7 +41,7 @@ def manager(hass, store, provider):
|
|||
return AuthManager(hass, store, {(provider.type, provider.id): provider}, {})
|
||||
|
||||
|
||||
async def test_create_new_credential(manager, provider):
|
||||
async def test_create_new_credential(manager, provider) -> None:
|
||||
"""Test that we create a new credential."""
|
||||
credentials = await provider.async_get_or_create_credentials(
|
||||
{"username": "good-user", "password": "good-pass"}
|
||||
|
@ -52,7 +52,7 @@ async def test_create_new_credential(manager, provider):
|
|||
assert user.is_active
|
||||
|
||||
|
||||
async def test_match_existing_credentials(store, provider):
|
||||
async def test_match_existing_credentials(store, provider) -> None:
|
||||
"""See if we match existing users."""
|
||||
existing = auth_models.Credentials(
|
||||
id=uuid.uuid4(),
|
||||
|
@ -68,24 +68,24 @@ async def test_match_existing_credentials(store, provider):
|
|||
assert credentials is existing
|
||||
|
||||
|
||||
async def test_invalid_username(provider):
|
||||
async def test_invalid_username(provider) -> None:
|
||||
"""Test we raise if incorrect user specified."""
|
||||
with pytest.raises(command_line.InvalidAuthError):
|
||||
await provider.async_validate_login("bad-user", "good-pass")
|
||||
|
||||
|
||||
async def test_invalid_password(provider):
|
||||
async def test_invalid_password(provider) -> None:
|
||||
"""Test we raise if incorrect password specified."""
|
||||
with pytest.raises(command_line.InvalidAuthError):
|
||||
await provider.async_validate_login("good-user", "bad-pass")
|
||||
|
||||
|
||||
async def test_good_auth(provider):
|
||||
async def test_good_auth(provider) -> None:
|
||||
"""Test nothing is raised with good credentials."""
|
||||
await provider.async_validate_login("good-user", "good-pass")
|
||||
|
||||
|
||||
async def test_good_auth_with_meta(manager, provider):
|
||||
async def test_good_auth_with_meta(manager, provider) -> None:
|
||||
"""Test metadata is added upon successful authentication."""
|
||||
provider.config[command_line.CONF_ARGS] = ["--with-meta"]
|
||||
provider.config[command_line.CONF_META] = True
|
||||
|
@ -102,7 +102,7 @@ async def test_good_auth_with_meta(manager, provider):
|
|||
assert user.is_active
|
||||
|
||||
|
||||
async def test_utf_8_username_password(provider):
|
||||
async def test_utf_8_username_password(provider) -> None:
|
||||
"""Test that we create a new credential."""
|
||||
credentials = await provider.async_get_or_create_credentials(
|
||||
{"username": "ßßß", "password": "äöü"}
|
||||
|
@ -110,7 +110,7 @@ async def test_utf_8_username_password(provider):
|
|||
assert credentials.is_new is True
|
||||
|
||||
|
||||
async def test_login_flow_validates(provider):
|
||||
async def test_login_flow_validates(provider) -> None:
|
||||
"""Test login flow."""
|
||||
flow = await provider.async_login_flow({})
|
||||
result = await flow.async_step_init()
|
||||
|
@ -129,7 +129,7 @@ async def test_login_flow_validates(provider):
|
|||
assert result["data"]["username"] == "good-user"
|
||||
|
||||
|
||||
async def test_strip_username(provider):
|
||||
async def test_strip_username(provider) -> None:
|
||||
"""Test authentication works with username with whitespace around."""
|
||||
flow = await provider.async_login_flow({})
|
||||
result = await flow.async_step_init(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue