示例#1
0
def test_get_remote_id_no_results():
    username = "******"
    provider_id = "DeathStar"
    expected_response = {
        "page":
        1,
        "page_size":
        200,
        "count":
        2,
        "results": [
            {
                "username": "******",
                "remote_id": "Kenobi"
            },
            {
                "username": "******",
                "remote_id": "Solo"
            },
        ]
    }
    responses.add(  # pylint: disable=no-member
        responses.GET,  # pylint: disable=no-member
        _url(
            "third_party_auth",
            "providers/{provider}/users/{user}".format(provider=provider_id,
                                                       user=username)),
        json=expected_response,
    )
    client = lms_api.ThirdPartyAuthApiClient()
    actual_response = client.get_remote_id(provider_id, username)
    assert actual_response is None
示例#2
0
def test_get_remote_id():
    username = "******"
    provider_id = "DeathStar"
    expected_response = {
        "page":
        1,
        "page_size":
        200,
        "count":
        2,
        "results": [
            {
                "username": "******",
                "remote_id": "LukeIamYrFather"
            },
            {
                "username": "******",
                "remote_id": "JamesEarlJones"
            },
        ]
    }
    responses.add(  # pylint: disable=no-member
        responses.GET,  # pylint: disable=no-member
        _url(
            "third_party_auth",
            "providers/{provider}/users/{user}".format(provider=provider_id,
                                                       user=username)),
        json=expected_response,
    )
    client = lms_api.ThirdPartyAuthApiClient()
    actual_response = client.get_remote_id(provider_id, username)
    assert actual_response == "LukeIamYrFather"
示例#3
0
def test_get_remote_id_not_found():
    username = "******"
    provider_id = "DeathStar"
    responses.add(responses.GET,
                  _url(
                      "third_party_auth",
                      "providers/{provider}/users/{user}".format(
                          provider=provider_id, user=username)),
                  status=404)
    client = lms_api.ThirdPartyAuthApiClient()
    actual_response = client.get_remote_id(provider_id, username)
    assert actual_response is None