File: test_room.py

package info (click to toggle)
pysmartthings 3.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,268 kB
  • sloc: python: 8,394; makefile: 3
file content (58 lines) | stat: -rw-r--r-- 1,751 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Tests for the room module."""

from aiohttp.hdrs import METH_GET
from aioresponses import aioresponses
from syrupy import SnapshotAssertion

from pysmartthings import SmartThings

from . import load_fixture
from .const import MOCK_URL, HEADERS


async def test_fetching_all_rooms(
    client: SmartThings,
    responses: aioresponses,
    snapshot: SnapshotAssertion,
) -> None:
    """Test getting all rooms for a location."""
    responses.get(
        f"{MOCK_URL}/v1/locations/397678e5-9995-4a39-9d9f-ae6ba310236b/rooms",
        status=200,
        body=load_fixture("rooms.json"),
    )
    assert await client.get_rooms("397678e5-9995-4a39-9d9f-ae6ba310236b") == snapshot
    responses.assert_called_once_with(
        f"{MOCK_URL}/v1/locations/397678e5-9995-4a39-9d9f-ae6ba310236b/rooms",
        METH_GET,
        headers=HEADERS,
        params=None,
        json=None,
    )


async def test_fetching_single_room(
    client: SmartThings,
    responses: aioresponses,
    snapshot: SnapshotAssertion,
) -> None:
    """Test getting a single room."""
    responses.get(
        f"{MOCK_URL}/v1/locations/397678e5-9995-4a39-9d9f-ae6ba310236b/rooms/7715151d-0314-457a-a82c-5ce48900e065",
        status=200,
        body=load_fixture("room.json"),
    )
    assert (
        await client.get_room(
            "397678e5-9995-4a39-9d9f-ae6ba310236b",
            "7715151d-0314-457a-a82c-5ce48900e065",
        )
        == snapshot
    )
    responses.assert_called_once_with(
        f"{MOCK_URL}/v1/locations/397678e5-9995-4a39-9d9f-ae6ba310236b/rooms/7715151d-0314-457a-a82c-5ce48900e065",
        METH_GET,
        headers=HEADERS,
        params=None,
        json=None,
    )