File: test_models.py

package info (click to toggle)
python-aiowithings 3.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,976 kB
  • sloc: python: 2,471; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 723 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
"""Asynchronous Python client for Withings."""

from __future__ import annotations

import json
from typing import TYPE_CHECKING, Any

import pytest

from aiowithings import MeasurementGroup

from . import load_fixture

if TYPE_CHECKING:
    from syrupy import SnapshotAssertion


@pytest.mark.parametrize(
    "file",
    [
        "measurement_list.json",
        "measurement_list_2.json",
    ],
)
def test_measurement_parsing(snapshot: SnapshotAssertion, file: str) -> None:
    """Test measurement parsing."""
    json_file: list[dict[str, Any]] = json.loads(load_fixture(file))

    measurements = [MeasurementGroup.from_api(measurement) for measurement in json_file]

    assert measurements == snapshot(name=file)