File: conftest.py

package info (click to toggle)
python-homeassistant-analytics 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,288 kB
  • sloc: python: 462; sh: 10; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Asynchronous Python client for Homeassistant Analytics."""

from collections.abc import AsyncGenerator, Generator

import aiohttp
from aioresponses import aioresponses
import pytest

from python_homeassistant_analytics import HomeassistantAnalyticsClient
from syrupy import SnapshotAssertion

from .syrupy import HomeassistantAnalyticsSnapshotExtension


@pytest.fixture(name="snapshot")
def snapshot_assertion(snapshot: SnapshotAssertion) -> SnapshotAssertion:
    """Return snapshot assertion fixture with the Homeassistant Analytics extension."""
    return snapshot.use_extension(HomeassistantAnalyticsSnapshotExtension)


@pytest.fixture(name="homeassistant_analytics_client")
async def client() -> AsyncGenerator[HomeassistantAnalyticsClient, None]:
    """Return a Spotify client."""
    async with (
        aiohttp.ClientSession(trust_env=True) as session,
        HomeassistantAnalyticsClient(
            session=session,
        ) as homeassistant_analytics_client,
    ):
        yield homeassistant_analytics_client


@pytest.fixture(name="responses")
def aioresponses_fixture() -> Generator[aioresponses, None, None]:
    """Return aioresponses fixture."""
    with aioresponses() as mocked_responses:
        yield mocked_responses