File: test_location.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 (50 lines) | stat: -rw-r--r-- 1,438 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
"""Tests for the Location 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_locations(
    client: SmartThings,
    responses: aioresponses,
    snapshot: SnapshotAssertion,
) -> None:
    """Test getting all locations."""
    responses.get(
        f"{MOCK_URL}/v1/locations", status=200, body=load_fixture("locations.json")
    )
    assert await client.get_locations() == snapshot
    responses.assert_called_once_with(
        f"{MOCK_URL}/v1/locations",
        METH_GET,
        headers=HEADERS,
        params=None,
        json=None,
    )


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