mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Improve type hints in smartthings tests (#123912)
This commit is contained in:
parent
2c99bd178c
commit
fa8f86b672
@ -91,7 +91,7 @@ async def setup_component(
|
|||||||
await async_setup_component(hass, "smartthings", {})
|
await async_setup_component(hass, "smartthings", {})
|
||||||
|
|
||||||
|
|
||||||
def _create_location():
|
def _create_location() -> Mock:
|
||||||
loc = Mock(Location)
|
loc = Mock(Location)
|
||||||
loc.name = "Test Location"
|
loc.name = "Test Location"
|
||||||
loc.location_id = str(uuid4())
|
loc.location_id = str(uuid4())
|
||||||
@ -99,19 +99,19 @@ def _create_location():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="location")
|
@pytest.fixture(name="location")
|
||||||
def location_fixture():
|
def location_fixture() -> Mock:
|
||||||
"""Fixture for a single location."""
|
"""Fixture for a single location."""
|
||||||
return _create_location()
|
return _create_location()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="locations")
|
@pytest.fixture(name="locations")
|
||||||
def locations_fixture(location):
|
def locations_fixture(location: Mock) -> list[Mock]:
|
||||||
"""Fixture for 2 locations."""
|
"""Fixture for 2 locations."""
|
||||||
return [location, _create_location()]
|
return [location, _create_location()]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="app")
|
@pytest.fixture(name="app")
|
||||||
async def app_fixture(hass, config_file):
|
async def app_fixture(hass: HomeAssistant, config_file: dict[str, str]) -> Mock:
|
||||||
"""Fixture for a single app."""
|
"""Fixture for a single app."""
|
||||||
app = Mock(AppEntity)
|
app = Mock(AppEntity)
|
||||||
app.app_name = APP_NAME_PREFIX + str(uuid4())
|
app.app_name = APP_NAME_PREFIX + str(uuid4())
|
||||||
@ -133,7 +133,7 @@ async def app_fixture(hass, config_file):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="app_oauth_client")
|
@pytest.fixture(name="app_oauth_client")
|
||||||
def app_oauth_client_fixture():
|
def app_oauth_client_fixture() -> Mock:
|
||||||
"""Fixture for a single app's oauth."""
|
"""Fixture for a single app's oauth."""
|
||||||
client = Mock(AppOAuthClient)
|
client = Mock(AppOAuthClient)
|
||||||
client.client_id = str(uuid4())
|
client.client_id = str(uuid4())
|
||||||
@ -150,7 +150,7 @@ def app_settings_fixture(app, config_file):
|
|||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
def _create_installed_app(location_id, app_id):
|
def _create_installed_app(location_id: str, app_id: str) -> Mock:
|
||||||
item = Mock(InstalledApp)
|
item = Mock(InstalledApp)
|
||||||
item.installed_app_id = str(uuid4())
|
item.installed_app_id = str(uuid4())
|
||||||
item.installed_app_status = InstalledAppStatus.AUTHORIZED
|
item.installed_app_status = InstalledAppStatus.AUTHORIZED
|
||||||
@ -161,7 +161,7 @@ def _create_installed_app(location_id, app_id):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="installed_app")
|
@pytest.fixture(name="installed_app")
|
||||||
def installed_app_fixture(location, app):
|
def installed_app_fixture(location: Mock, app: Mock) -> Mock:
|
||||||
"""Fixture for a single installed app."""
|
"""Fixture for a single installed app."""
|
||||||
return _create_installed_app(location.location_id, app.app_id)
|
return _create_installed_app(location.location_id, app.app_id)
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ def device_fixture(location):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="config_entry")
|
@pytest.fixture(name="config_entry")
|
||||||
def config_entry_fixture(hass, installed_app, location):
|
def config_entry_fixture(installed_app: Mock, location: Mock) -> MockConfigEntry:
|
||||||
"""Fixture representing a config entry."""
|
"""Fixture representing a config entry."""
|
||||||
data = {
|
data = {
|
||||||
CONF_ACCESS_TOKEN: str(uuid4()),
|
CONF_ACCESS_TOKEN: str(uuid4()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user