File: conftest.py

package info (click to toggle)
switchbot-api 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 292 kB
  • sloc: python: 406; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,032 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
"""Asynchronous Python client for SwitchBot."""

from collections.abc import AsyncGenerator, Generator

from aiohttp import ClientSession
from aioresponses import aioresponses
import pytest

from switchbot_api import SwitchBotAPI
from syrupy import SnapshotAssertion

from .syrupy import SwitchBotSnapshotExtension


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


@pytest.fixture
async def client() -> AsyncGenerator[SwitchBotAPI, None]:
    """Return a SwitchBot client."""
    async with (
        ClientSession() as session,
        SwitchBotAPI("token", "secret", session) as client,
    ):
        yield client


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