Ejemplo n.º 1
0
def new_profile_config(
    profile: str,
    user_id: int,
    api_response_user_get_device: UserGetDeviceResponse | Exception
    | None = None,
    api_response_measure_get_meas: MeasureGetMeasResponse | Exception
    | None = None,
    api_response_sleep_get_summary: SleepGetSummaryResponse | Exception
    | None = None,
    api_response_notify_list: NotifyListResponse | Exception | None = None,
    api_response_notify_revoke: Exception | None = None,
) -> ProfileConfig:
    """Create a new profile config immutable object."""
    return ProfileConfig(
        profile=profile,
        user_id=user_id,
        api_response_user_get_device=api_response_user_get_device
        or UserGetDeviceResponse(devices=[]),
        api_response_measure_get_meas=api_response_measure_get_meas
        or MeasureGetMeasResponse(
            measuregrps=[],
            more=False,
            offset=0,
            timezone=dt_util.UTC,
            updatetime=arrow.get(12345),
        ),
        api_response_sleep_get_summary=api_response_sleep_get_summary
        or SleepGetSummaryResponse(more=False, offset=0, series=[]),
        api_response_notify_list=api_response_notify_list
        or NotifyListResponse(profiles=[]),
        api_response_notify_revoke=api_response_notify_revoke,
    )
Ejemplo n.º 2
0
def test_sleep_get_summary(withings_api: WithingsApi) -> None:
    """Test function."""
    responses_add_sleep_get_summary()
    assert withings_api.sleep_get_summary() == SleepGetSummaryResponse(
        more=False,
        offset=1,
        series=(
            GetSleepSummarySerie(
                date=arrow.get("2018-10-30").replace(tzinfo=TIMEZONE0),
                enddate=arrow.get(1540897020).replace(tzinfo=TIMEZONE0),
                model=SleepModel.TRACKER,
                modified=arrow.get(1540897246).replace(tzinfo=TIMEZONE0),
                startdate=arrow.get(1540857420).replace(tzinfo=TIMEZONE0),
                timezone=TIMEZONE0,
                data=GetSleepSummaryData(
                    deepsleepduration=110,
                    durationtosleep=111,
                    durationtowakeup=112,
                    lightsleepduration=113,
                    wakeupcount=114,
                    wakeupduration=116,
                    remsleepduration=116,
                    hr_average=117,
                    hr_min=118,
                    hr_max=119,
                    rr_average=120,
                    rr_min=121,
                    rr_max=122,
                ),
            ),
            GetSleepSummarySerie(
                date=arrow.get("2018-10-31").replace(tzinfo=TIMEZONE1),
                enddate=arrow.get(1540973400).replace(tzinfo=TIMEZONE1),
                model=SleepModel.TRACKER,
                modified=arrow.get(1541020749).replace(tzinfo=TIMEZONE1),
                startdate=arrow.get(1540944960).replace(tzinfo=TIMEZONE1),
                timezone=TIMEZONE1,
                data=GetSleepSummaryData(
                    deepsleepduration=210,
                    durationtosleep=211,
                    durationtowakeup=212,
                    lightsleepduration=213,
                    wakeupcount=214,
                    wakeupduration=216,
                    remsleepduration=216,
                    hr_average=217,
                    hr_min=218,
                    hr_max=219,
                    rr_average=220,
                    rr_min=221,
                    rr_max=222,
                ),
            ),
        ),
    )
Ejemplo n.º 3
0
def test_sleep_get_summary(withings_api: WithingsApi) -> None:
    """Test function."""
    responses_add_sleep_get_summary()
    assert withings_api.sleep_get_summary() == SleepGetSummaryResponse(
        more=False,
        offset=1,
        series=(
            GetSleepSummarySerie(
                date=arrow.get("2018-10-30").to(TIMEZONE0),
                enddate=arrow.get(1540897020).to(TIMEZONE0),
                model=SleepModel.TRACKER,
                modified=arrow.get(1540897246).to(TIMEZONE0),
                startdate=arrow.get(1540857420).to(TIMEZONE0),
                timezone=TIMEZONE0,
                data=GetSleepSummaryData(
                    breathing_disturbances_intensity=110,
                    deepsleepduration=111,
                    durationtosleep=112,
                    durationtowakeup=113,
                    hr_average=114,
                    hr_max=115,
                    hr_min=116,
                    lightsleepduration=117,
                    remsleepduration=118,
                    rr_average=119,
                    rr_max=120,
                    rr_min=121,
                    sleep_score=122,
                    snoring=123,
                    snoringepisodecount=124,
                    wakeupcount=125,
                    wakeupduration=126,
                ),
            ),
            GetSleepSummarySerie(
                date=arrow.get("2018-10-31").to(TIMEZONE1),
                enddate=arrow.get(1540973400).to(TIMEZONE1),
                model=SleepModel.TRACKER,
                modified=arrow.get(1541020749).to(TIMEZONE1),
                startdate=arrow.get(1540944960).to(TIMEZONE1),
                timezone=TIMEZONE1,
                data=GetSleepSummaryData(
                    breathing_disturbances_intensity=210,
                    deepsleepduration=211,
                    durationtosleep=212,
                    durationtowakeup=213,
                    hr_average=214,
                    hr_max=215,
                    hr_min=216,
                    lightsleepduration=217,
                    remsleepduration=218,
                    rr_average=219,
                    rr_max=220,
                    rr_min=221,
                    sleep_score=222,
                    snoring=223,
                    snoringepisodecount=224,
                    wakeupcount=225,
                    wakeupduration=226,
                ),
            ),
        ),
    )
Ejemplo n.º 4
0
 api_response_sleep_get_summary=SleepGetSummaryResponse(
     more=False,
     offset=0,
     series=(
         GetSleepSummarySerie(
             timezone=pytz.UTC,
             model=SleepModel.SLEEP_MONITOR,
             startdate=arrow.get("2019-02-01"),
             enddate=arrow.get("2019-02-01"),
             date=arrow.get("2019-02-01"),
             modified=arrow.get(12345),
             data=GetSleepSummaryData(
                 breathing_disturbances_intensity=110,
                 deepsleepduration=111,
                 durationtosleep=112,
                 durationtowakeup=113,
                 hr_average=114,
                 hr_max=115,
                 hr_min=116,
                 lightsleepduration=117,
                 remsleepduration=118,
                 rr_average=119,
                 rr_max=120,
                 rr_min=121,
                 sleep_score=122,
                 snoring=123,
                 snoringepisodecount=124,
                 wakeupcount=125,
                 wakeupduration=126,
             ),
         ),
         GetSleepSummarySerie(
             timezone=pytz.UTC,
             model=SleepModel.SLEEP_MONITOR,
             startdate=arrow.get("2019-02-01"),
             enddate=arrow.get("2019-02-01"),
             date=arrow.get("2019-02-01"),
             modified=arrow.get(12345),
             data=GetSleepSummaryData(
                 breathing_disturbances_intensity=210,
                 deepsleepduration=211,
                 durationtosleep=212,
                 durationtowakeup=213,
                 hr_average=214,
                 hr_max=215,
                 hr_min=216,
                 lightsleepduration=217,
                 remsleepduration=218,
                 rr_average=219,
                 rr_max=220,
                 rr_min=221,
                 sleep_score=222,
                 snoring=223,
                 snoringepisodecount=224,
                 wakeupcount=225,
                 wakeupduration=226,
             ),
         ),
     ),
 ),