diff --git a/homeassistant/components/google_tasks/quality_scale.yaml b/homeassistant/components/google_tasks/quality_scale.yaml index 671b744d080..79d216709e5 100644 --- a/homeassistant/components/google_tasks/quality_scale.yaml +++ b/homeassistant/components/google_tasks/quality_scale.yaml @@ -31,16 +31,12 @@ rules: # Silver log-when-unavailable: done config-entry-unloading: done - reauthentication-flow: - status: todo - comment: Missing a test that reauthenticates with the wrong account + reauthentication-flow: done action-exceptions: done docs-installation-parameters: todo integration-owner: done parallel-updates: done - test-coverage: - status: todo - comment: Test coverage for __init__.py is not above 95% yet + test-coverage: done docs-configuration-parameters: todo entity-unavailable: done diff --git a/tests/components/google_tasks/test_init.py b/tests/components/google_tasks/test_init.py index 4bb2bd1eed7..9ad8c887a66 100644 --- a/tests/components/google_tasks/test_init.py +++ b/tests/components/google_tasks/test_init.py @@ -6,6 +6,7 @@ from http import HTTPStatus import time from unittest.mock import Mock +from aiohttp import ClientError from httplib2 import Response import pytest @@ -72,20 +73,28 @@ async def test_expired_token_refresh_success( @pytest.mark.parametrize( - ("expires_at", "status", "expected_state"), + ("expires_at", "status", "exc", "expected_state"), [ ( time.time() - 3600, http.HTTPStatus.UNAUTHORIZED, + None, ConfigEntryState.SETUP_ERROR, ), ( time.time() - 3600, http.HTTPStatus.INTERNAL_SERVER_ERROR, + None, + ConfigEntryState.SETUP_RETRY, + ), + ( + time.time() - 3600, + None, + ClientError("error"), ConfigEntryState.SETUP_RETRY, ), ], - ids=["unauthorized", "internal_server_error"], + ids=["unauthorized", "internal_server_error", "client_error"], ) async def test_expired_token_refresh_failure( hass: HomeAssistant, @@ -93,7 +102,8 @@ async def test_expired_token_refresh_failure( aioclient_mock: AiohttpClientMocker, config_entry: MockConfigEntry, setup_credentials: None, - status: http.HTTPStatus, + status: http.HTTPStatus | None, + exc: Exception | None, expected_state: ConfigEntryState, ) -> None: """Test failure while refreshing token with a transient error.""" @@ -102,6 +112,7 @@ async def test_expired_token_refresh_failure( aioclient_mock.post( OAUTH2_TOKEN, status=status, + exc=exc, ) await integration_setup()