def test_project(project_list, length): def response(url, *args, **kwargs): data = { "data": { "relationships": { "nodes": { "links": { "related": { "href": user_nodes_url } } } } } } print(url) if url == user_me_url: return FakeResponse(200, data) else: return FakeResponse(200, {"data": project_list}) OSFCore_get.side_effect = response osf = OSF() osf.login("*****@*****.**", "secret_password") projects = osf.projects() calls = [call(user_me_url), call(user_nodes_url)] OSFCore_get.assert_has_calls(calls) assert isinstance(projects, list) assert len(projects) == length for index, proj in enumerate(projects): assert isinstance(proj, Project) assert proj.id == project_list[index]["data"]["id"]
def test_login_token(session_token_auth): osf = OSF() assert not session_token_auth.called osf.login(token="asdfg") session_token_auth.assert_called_with("asdfg")
def test_login_username_password(session_basic_auth): osf = OSF() assert not session_basic_auth.called osf.login('*****@*****.**', 'secret_password') session_basic_auth.assert_called_with('*****@*****.**', 'secret_password')