diff --git a/tests/components/august/mocks.py b/tests/components/august/mocks.py index a0f5b55a607..c2ab8ce743c 100644 --- a/tests/components/august/mocks.py +++ b/tests/components/august/mocks.py @@ -18,6 +18,7 @@ from yalexs.activity import ( ACTIVITY_ACTIONS_LOCK_OPERATION, SOURCE_LOCK_OPERATE, SOURCE_LOG, + Activity, BridgeOperationActivity, DoorbellDingActivity, DoorbellMotionActivity, @@ -65,8 +66,8 @@ def _timetoken(): @patch("yalexs.manager.gateway.ApiAsync") @patch("yalexs.manager.gateway.AuthenticatorAsync.async_authenticate") async def _mock_setup_august( - hass, api_instance, pubnub_mock, authenticate_mock, api_mock, brand -): + hass: HomeAssistant, api_instance, pubnub_mock, authenticate_mock, api_mock, brand +) -> MockConfigEntry: """Set up august integration.""" authenticate_mock.side_effect = MagicMock( return_value=_mock_august_authentication( @@ -107,13 +108,13 @@ async def _create_august_with_devices( async def _create_august_api_with_devices( - hass, - devices, - api_call_side_effects=None, - activities=None, - pubnub=None, - brand=Brand.AUGUST, -): + hass: HomeAssistant, + devices: Iterable[LockDetail | DoorbellDetail], + api_call_side_effects: dict[str, Any] | None = None, + activities: list[Any] | None = None, + pubnub: AugustPubNub | None = None, + brand: Brand = Brand.AUGUST, +) -> tuple[MockConfigEntry, MagicMock]: if api_call_side_effects is None: api_call_side_effects = {} if pubnub is None: @@ -215,7 +216,10 @@ async def _create_august_api_with_devices( async def _mock_setup_august_with_api_side_effects( - hass, api_call_side_effects, pubnub, brand=Brand.AUGUST + hass: HomeAssistant, + api_call_side_effects: dict[str, Any], + pubnub: AugustPubNub, + brand: Brand = Brand.AUGUST, ): api_instance = MagicMock(name="Api", brand=brand) @@ -335,19 +339,21 @@ def _mock_august_lock_data(lockid="mocklockid1", houseid="mockhouseid1"): } -async def _mock_operative_august_lock_detail(hass): +async def _mock_operative_august_lock_detail(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.online.json") -async def _mock_lock_with_offline_key(hass): +async def _mock_lock_with_offline_key(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.online_with_keys.json") -async def _mock_inoperative_august_lock_detail(hass): +async def _mock_inoperative_august_lock_detail(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.offline.json") -async def _mock_activities_from_fixture(hass, path): +async def _mock_activities_from_fixture( + hass: HomeAssistant, path: str +) -> list[Activity]: json_dict = await _load_json_fixture(hass, path) activities = [] for activity_json in json_dict: @@ -358,32 +364,32 @@ async def _mock_activities_from_fixture(hass, path): return activities -async def _mock_lock_from_fixture(hass, path): +async def _mock_lock_from_fixture(hass: HomeAssistant, path: str) -> LockDetail: json_dict = await _load_json_fixture(hass, path) return LockDetail(json_dict) -async def _mock_doorbell_from_fixture(hass, path): +async def _mock_doorbell_from_fixture(hass: HomeAssistant, path: str) -> DoorbellDetail: json_dict = await _load_json_fixture(hass, path) return DoorbellDetail(json_dict) -async def _load_json_fixture(hass, path): +async def _load_json_fixture(hass: HomeAssistant, path: str) -> Any: fixture = await hass.async_add_executor_job( load_fixture, os.path.join("august", path) ) return json.loads(fixture) -async def _mock_doorsense_enabled_august_lock_detail(hass): +async def _mock_doorsense_enabled_august_lock_detail(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.online_with_doorsense.json") -async def _mock_doorsense_missing_august_lock_detail(hass): +async def _mock_doorsense_missing_august_lock_detail(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.online_missing_doorsense.json") -async def _mock_lock_with_unlatch(hass): +async def _mock_lock_with_unlatch(hass: HomeAssistant) -> LockDetail: return await _mock_lock_from_fixture(hass, "get_lock.online_with_unlatch.json") @@ -411,7 +417,7 @@ def _mock_door_operation_activity(lock, action, offset): ) -def _activity_from_dict(activity_dict): +def _activity_from_dict(activity_dict: dict[str, Any]) -> Activity | None: action = activity_dict.get("action") activity_dict["dateTime"] = time.time() * 1000 diff --git a/tests/components/august/test_gateway.py b/tests/components/august/test_gateway.py index 74266397ed5..1603aeb3ecb 100644 --- a/tests/components/august/test_gateway.py +++ b/tests/components/august/test_gateway.py @@ -22,14 +22,14 @@ async def test_refresh_access_token(hass: HomeAssistant) -> None: @patch("yalexs.manager.gateway.AuthenticatorAsync.should_refresh") @patch("yalexs.manager.gateway.AuthenticatorAsync.async_refresh_access_token") async def _patched_refresh_access_token( - hass, - new_token, - new_token_expire_time, + hass: HomeAssistant, + new_token: str, + new_token_expire_time: int, refresh_access_token_mock, should_refresh_mock, authenticate_mock, async_get_operable_locks_mock, -): +) -> None: authenticate_mock.side_effect = MagicMock( return_value=_mock_august_authentication( "original_token", 1234, AuthenticationState.AUTHENTICATED