Exemple #1
0
def test_sleep_get(withings_api: WithingsApi) -> None:
    """Test function."""
    responses_add_sleep_get()
    assert withings_api.sleep_get() == SleepGetResponse(
        model=SleepModel.TRACKER,
        series=(
            SleepGetSerie(
                startdate=arrow.get(1387235398),
                state=SleepState.AWAKE,
                enddate=arrow.get(1387235758),
                hr=(),
                rr=(),
                snoring=(),
            ),
            SleepGetSerie(
                startdate=arrow.get(1387243618),
                state=SleepState.LIGHT,
                enddate=arrow.get(1387244518),
                hr=(
                    SleepGetTimestampValue(arrow.get(1387243618), 12),
                    SleepGetTimestampValue(arrow.get(1387243700), 34),
                ),
                rr=(
                    SleepGetTimestampValue(arrow.get(1387243618), 45),
                    SleepGetTimestampValue(arrow.get(1387243700), 67),
                ),
                snoring=(
                    SleepGetTimestampValue(arrow.get(1387243618), 78),
                    SleepGetTimestampValue(arrow.get(1387243700), 90),
                ),
            ),
        ),
    )
def test_sleep_get_unknown(withings_api: WithingsApi) -> None:
    """Test function."""
    responses_add_sleep_get(_UNKNOWN_INT)
    assert withings_api.sleep_get(
        data_fields=GetSleepField) == SleepGetResponse(
            model=SleepModel.UNKNOWN,
            series=(
                SleepGetSerie(
                    startdate=arrow.get(1387235398),
                    state=SleepState.AWAKE,
                    enddate=arrow.get(1387235758),
                    hr=(),
                    rr=(),
                    snoring=(),
                ),
                SleepGetSerie(
                    startdate=arrow.get(1387243618),
                    state=SleepState.LIGHT,
                    enddate=arrow.get(1387244518),
                    hr=(
                        SleepGetTimestampValue(timestamp=arrow.get(1387243618),
                                               value=12),
                        SleepGetTimestampValue(timestamp=arrow.get(1387243700),
                                               value=34),
                    ),
                    rr=(
                        SleepGetTimestampValue(timestamp=arrow.get(1387243618),
                                               value=45),
                        SleepGetTimestampValue(timestamp=arrow.get(1387243700),
                                               value=67),
                    ),
                    snoring=(
                        SleepGetTimestampValue(timestamp=arrow.get(1387243618),
                                               value=78),
                        SleepGetTimestampValue(timestamp=arrow.get(1387243700),
                                               value=90),
                    ),
                ),
                SleepGetSerie(
                    startdate=arrow.get(1387235398),
                    state=SleepState.UNKNOWN,
                    enddate=arrow.get(1387235758),
                    hr=(),
                    rr=(),
                    snoring=(),
                ),
            ),
        )