"""
Fitbit Web API Explorer

Fitbit provides a Web API for accessing data from Fitbit activity trackers, Aria scale, and manually entered logs. Anyone can develop an application to access and modify a Fitbit user's data on their behalf, so long as it complies with Fitbit Platform Terms of Service. These Swagger UI docs do not currently support making Fitbit API requests directly. In order to make a request, construct a request for the appropriate endpoint using this documentation, and then add an Authorization header to each request with an access token obtained using the steps outlined here: https://dev.fitbit.com/build/reference/web-api/developer-guide/authorization/.

The version of the OpenAPI document: 1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from collections.abc import AsyncGenerator, Callable
from datetime import date
from typing import Any, Dict

import pytest

import fitbit_web_api


@pytest.fixture
async def breathing_rate_api(
    api_client: fitbit_web_api.ApiClient,
) -> AsyncGenerator[fitbit_web_api.BreathingRateApi, None]:
    yield fitbit_web_api.BreathingRateApi(api_client)


async def test_get_breathing_rate_summary_by_date(
    breathing_rate_api: fitbit_web_api.BreathingRateApi,
    responses: Dict[str, Any],
    load_test_data: Callable[[str], Any],
) -> None:
    """Test case for get_breathing_rate_summary_by_date."""
    responses["/1/user/-/br/date/2021-10-25.json"] = load_test_data(
        "breathing_rate.json"
    )

    result = await breathing_rate_api.get_breathing_rate_summary_by_date(
        var_date="2021-10-25",
    )

    assert result.br is not None
    assert len(result.br) == 1
    assert result.br[0].date_time == date(2021, 10, 25)
    assert result.br[0].value.breathing_rate == 17.8


async def test_get_breathing_rate_summary_by_interval(
    breathing_rate_api: fitbit_web_api.BreathingRateApi,
    responses: Dict[str, Any],
    load_test_data: Callable[[str], Any],
) -> None:
    """Test case for get_breathing_rate_summary_by_interval."""
    responses["/1/user/-/br/date/2021-10-25/2021-10-25.json"] = load_test_data(
        "breathing_rate.json"
    )

    result = await breathing_rate_api.get_breathing_rate_summary_by_interval(
        start_date="2021-10-25",
        end_date="2021-10-25",
    )

    assert result.br is not None
    assert len(result.br) == 1
    assert result.br[0].date_time == date(2021, 10, 25)
    assert result.br[0].value.breathing_rate == 17.8
