Skip to content

Commit

Permalink
Improve type hints in evil_genius_labs tests (home-assistant#120677)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jun 27, 2024
1 parent 440928b commit bccd5c8
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions tests/components/evil_genius_labs/conftest.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
"""Test helpers for Evil Genius Labs."""

import json
from typing import Any
from unittest.mock import patch

import pytest
from typing_extensions import AsyncGenerator

from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util.json import JsonObjectType

from tests.common import MockConfigEntry, load_fixture
from tests.common import (
MockConfigEntry,
load_json_array_fixture,
load_json_object_fixture,
)


@pytest.fixture(scope="package")
def all_fixture():
def all_fixture() -> dict[str, Any]:
"""Fixture data."""
data = json.loads(load_fixture("data.json", "evil_genius_labs"))
data = load_json_array_fixture("data.json", "evil_genius_labs")
return {item["name"]: item for item in data}


@pytest.fixture(scope="package")
def info_fixture():
def info_fixture() -> JsonObjectType:
"""Fixture info."""
return json.loads(load_fixture("info.json", "evil_genius_labs"))
return load_json_object_fixture("info.json", "evil_genius_labs")


@pytest.fixture(scope="package")
def product_fixture():
def product_fixture() -> dict[str, str]:
"""Fixture info."""
return {"productName": "Fibonacci256"}


@pytest.fixture
def config_entry(hass):
def config_entry(hass: HomeAssistant) -> MockConfigEntry:
"""Evil genius labs config entry."""
entry = MockConfigEntry(domain="evil_genius_labs", data={"host": "192.168.1.113"})
entry.add_to_hass(hass)
Expand All @@ -39,8 +47,13 @@ def config_entry(hass):

@pytest.fixture
async def setup_evil_genius_labs(
hass, config_entry, all_fixture, info_fixture, product_fixture, platforms
):
hass: HomeAssistant,
config_entry: MockConfigEntry,
all_fixture: dict[str, Any],
info_fixture: JsonObjectType,
product_fixture: dict[str, str],
platforms: list[Platform],
) -> AsyncGenerator[None]:
"""Test up Evil Genius Labs instance."""
with (
patch(
Expand Down

0 comments on commit bccd5c8

Please sign in to comment.