예제 #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,
    )
예제 #2
0
def test_user_get_device(withings_api: WithingsApi) -> None:
    """Test function."""
    responses_add_user_get_device()
    assert withings_api.user_get_device() == UserGetDeviceResponse(devices=(
        UserGetDeviceDevice(
            type="type0",
            model="model0",
            battery="battery0",
            deviceid="deviceid0",
            timezone=TIMEZONE0,
        ),
        UserGetDeviceDevice(
            type="type1",
            model="model1",
            battery="battery1",
            deviceid="deviceid1",
            timezone=TIMEZONE1,
        ),
    ))

    assert_url_path(responses.calls[0].request.url, "/v2/user")
    assert_url_query_equals(responses.calls[0].request.url,
                            {"action": "getdevice"})