File: conftest.py

package info (click to toggle)
pysmartthings 3.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,352 kB
  • sloc: python: 8,679; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 1,145 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
38
"""Define test configuration."""

from collections.abc import AsyncGenerator, Generator

from aiohttp import ClientSession
from aioresponses import aioresponses

from pysmartthings import SmartThings
import pytest
from syrupy import SnapshotAssertion

from .syrupy import SmartThingsSnapshotExtension


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


@pytest.fixture
async def client() -> AsyncGenerator[SmartThings, None]:
    """Return a SmartThings client."""
    async with (
        ClientSession() as session,
        SmartThings(
            session=session,
        ) as smartthings_client,
    ):
        smartthings_client.authenticate("token")
        yield smartthings_client


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