File: __init__.py

package info (click to toggle)
python-aioshelly 13.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: python: 6,867; makefile: 7; sh: 3
file content (21 lines) | stat: -rw-r--r-- 616 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
"""Tests for RPC device."""

import asyncio
import pathlib
from typing import Any

from orjson import loads


def get_device_fixture_path(device: str, filename: str) -> pathlib.Path:
    """Get path of a device fixture."""
    return pathlib.Path(__file__).parent.joinpath("fixtures", device, filename)


async def load_device_fixture(device: str, filename: str) -> dict[str, Any]:
    """Load a device fixture."""
    fixture_path = get_device_fixture_path(device, filename)
    json_bytes = await asyncio.get_running_loop().run_in_executor(
        None, fixture_path.read_bytes
    )
    return loads(json_bytes)