Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 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")
Ejemplo n.º 3
0
 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")
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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'])
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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