Commit 4ce259a6 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis

Rename AstakosClient's authenticate method to getUserInfo

parent e3ae6f4d
......@@ -168,8 +168,8 @@ class AstakosClient():
return simplejson.loads(unicode(data))
# ------------------------
def authenticate(self, token, usage=False):
"""Check if user is authenticated Astakos user
def getUserInfo(self, token, usage=False):
"""Authenticate user and get user's info as a dictionary
Keyword arguments:
token -- user's token (string)
......
......@@ -429,7 +429,7 @@ class TestCallAstakos(unittest.TestCase):
class TestAuthenticate(unittest.TestCase):
"""Test cases for function authenticate"""
"""Test cases for function getUserInfo"""
# ----------------------------------
# Test the response we get if we don't have internet access
......@@ -439,7 +439,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest([_requestOffline])
try:
client = AstakosClient("https://example.com", retry=3)
client.authenticate(token_1)
client.getUserInfo(token_1)
except AstakosClientException:
pass
else:
......@@ -452,7 +452,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest([_requestOk])
try:
client = AstakosClient("https://example.com", use_pool=pool)
client.authenticate(token)
client.getUserInfo(token)
except Unauthorized:
pass
except Exception:
......@@ -474,7 +474,7 @@ class TestAuthenticate(unittest.TestCase):
_mockRequest([_requestOk])
try:
client = AstakosClient("https://example.com", use_pool=pool)
auth_info = client.authenticate(token, usage=usage)
auth_info = client.getUserInfo(token, usage=usage)
except:
self.fail("Shouldn't raise an Exception")
self.assertEqual(user_info, auth_info)
......@@ -516,12 +516,12 @@ class TestAuthenticate(unittest.TestCase):
# ----------------------------------
# Test retry functionality
def test_OfflineRetry(self):
"""Test retry functionality for authentication"""
"""Test retry functionality for getUserInfo"""
global token_1, user_1
_mockRequest([_requestOffline, _requestOffline, _requestOk])
try:
client = AstakosClient("https://example.com", retry=2)
auth_info = client.authenticate(token_1, usage=True)
auth_info = client.getUserInfo(token_1, usage=True)
except:
self.fail("Shouldn't raise an Exception")
self.assertEqual(user_1, auth_info)
......
......@@ -34,7 +34,7 @@ demonstrates how to get user's info using ``astakosclient``.
from astakosclient import AstakosClient
client = AstakosClient("https://accounts.example.com")
user_info = client.authenticate("UQpYas7ElzWGD5yCcEXtjw==")
user_info = client.getUserInfo("UQpYas7ElzWGD5yCcEXtjw==")
print user_info['username']
Another example where we ask for the username of a user with UUID:
......@@ -67,7 +67,7 @@ retry=0, use_pool=False, pool_size=8, logger=None\ **)**
This class provides the following methods:
**authenticate(**\ token, usage=False\ **)**
**getUserInfo(**\ token, usage=False\ **)**
Given a valid authentication token it returns a dict with the
correspoinding user's info. If usage is set to True more
information about user's resources will be returned.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment