33from copy import deepcopy
44from http import HTTPStatus
55from typing import Any
6- from unittest .mock import patch
76
87from doorbirdpy import DoorBirdScheduleEntry
98import pytest
1615)
1716from homeassistant .core import HomeAssistant
1817
19- from . import VALID_CONFIG , get_mock_doorbird_api
18+ from . import VALID_CONFIG
2019from .conftest import DoorbirdMockerType
2120
2221from tests .common import MockConfigEntry
@@ -106,8 +105,7 @@ async def test_stale_favorites_filtered_by_url(
106105
107106async def test_custom_url_used_for_favorites (
108107 hass : HomeAssistant ,
109- doorbird_info : dict [str , Any ],
110- doorbird_schedule : list [DoorBirdScheduleEntry ],
108+ doorbird_mocker : DoorbirdMockerType ,
111109) -> None :
112110 """Test that custom URL override is used instead of get_url."""
113111 custom_url = "https://my-custom-url.example.com:8443"
@@ -133,19 +131,7 @@ async def test_custom_url_used_for_favorites(
133131 data = config_with_custom_url ,
134132 options = {CONF_EVENTS : [DEFAULT_DOORBELL_EVENT , DEFAULT_MOTION_EVENT ]},
135133 )
136- api = get_mock_doorbird_api (
137- info = doorbird_info ,
138- schedule = doorbird_schedule ,
139- favorites = favorites ,
140- )
141- entry .add_to_hass (hass )
142- # Don't patch get_url - we want to verify custom_url takes precedence
143- with patch (
144- "homeassistant.components.doorbird.DoorBird" ,
145- return_value = api ,
146- ):
147- await hass .config_entries .async_setup (entry .entry_id )
148- await hass .async_block_till_done ()
134+ await doorbird_mocker (entry = entry , favorites = favorites )
149135
150136 # Should have 2 event entities using the custom URL
151137 event_entities = hass .states .async_all ("event" )
0 commit comments