def test_no_username(self): global token, auth_url try: client = AstakosClient(token['id'], auth_url) client.get_username("1234") except NoUserName: pass except: self.fail("Should have raised NoDisplayName exception") else: self.fail("Should have raised NoDisplayName exception")
def test_no_username(self): global token_1 _mock_request([_request_ok]) try: client = AstakosClient("https://example.com") client.get_username(token_1, "1234") except NoUserName: pass except: self.fail("Should have raised NoDisplayName exception") else: self.fail("Should have raised NoDisplayName exception")
def test_username(self): """Test get_username""" global token, user, auth_url try: client = AstakosClient(token['id'], auth_url, use_pool=False, retry=2) info = client.get_username(user['id']) except Exception, e: self.fail("Shouldn't raise an Exception: %s" % e)
def test_username_user_one(self): """Test get_username for User One""" global token_2, user_1 _mock_request([_request_offline, _request_ok]) try: client = AstakosClient( "https://example.com", use_pool=True, retry=2) info = client.get_username(token_2, user_1['uuid']) except: self.fail("Shouldn't raise an Exception") self.assertEqual(info, user_1['username'])
def retrieve_displayname(token, uuid, fail_silently=True): astakos = AstakosClient(token, ASTAKOS_AUTH_URL, retry=2, use_pool=True, logger=logger) try: displayname = astakos.get_username(uuid) except NoUserName: if not fail_silently: raise ItemNotExists(uuid) else: # just return the uuid return uuid return displayname