def test_get_username_from_remote_id(): remote_id = "LukeIamYrFather" provider_id = "DeathStar" expected_response = { "page": 1, "page_size": 200, "count": 1, "results": [{ "username": "******", "remote_id": "LukeIamYrFather" }] } responses.add( responses.GET, _url( "third_party_auth", "providers/{provider}/users?remote_id={user}".format( provider=provider_id, user=remote_id)), match_querystring=True, json=expected_response, ) client = lms_api.ThirdPartyAuthApiClient('staff-user-goes-here') actual_response = client.get_username_from_remote_id( provider_id, remote_id) assert actual_response == "Darth"
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( responses.GET, _url( "third_party_auth", "providers/{provider}/users?username={user}".format( provider=provider_id, user=username)), match_querystring=True, json=expected_response, ) client = lms_api.ThirdPartyAuthApiClient('staff-user-goes-here') actual_response = client.get_remote_id(provider_id, username) assert actual_response is None
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( responses.GET, _url( "third_party_auth", "providers/{provider}/users?username={user}".format( provider=provider_id, user=username)), match_querystring=True, json=expected_response, ) client = lms_api.ThirdPartyAuthApiClient() actual_response = client.get_remote_id(provider_id, username) assert actual_response == "LukeIamYrFather"
def test_get_remote_id_not_found(): username = "******" provider_id = "DeathStar" responses.add(responses.GET, _url( "third_party_auth", "providers/{provider}/users?username={user}".format( provider=provider_id, user=username)), match_querystring=True, status=404) client = lms_api.ThirdPartyAuthApiClient('staff-user-goes-here') actual_response = client.get_remote_id(provider_id, username) assert actual_response is None