예제 #1
0
 def test_get_quotas_without_token(self):
     """Test function call of get_quotas without token"""
     _mock_request([_request_ok])
     try:
         client = AstakosClient("https://example.com")
         client.get_quotas(None)
     except Unauthorized:
         pass
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     else:
         self.fail("Should have raised Unauthorized Exception")
예제 #2
0
 def test_get_quotas_unauthorized(self):
     """Test function call of get_quotas with wrong token"""
     global auth_url
     token = "buahfhsda"
     try:
         client = AstakosClient(token, auth_url)
         client.get_quotas()
     except Unauthorized:
         pass
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     else:
         self.fail("Should have raised Unauthorized Exception")
예제 #3
0
파일: tests.py 프로젝트: AthinaB/synnefo
 def test_get_quotas_unauthorized(self):
     """Test function call of get_quotas with wrong token"""
     global auth_url
     token = "buahfhsda"
     try:
         client = AstakosClient(token, auth_url)
         client.get_quotas()
     except Unauthorized:
         pass
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     else:
         self.fail("Should have raised Unauthorized Exception")
예제 #4
0
파일: util.py 프로젝트: cstavr/synnefo
def get_pithos_usage(token):
    """Get Pithos Usage from astakos."""
    astakos = AstakosClient(ASTAKOS_BASE_URL, retry=2, use_pool=True,
                            logger=logger)
    quotas = astakos.get_quotas(token)['system']
    pithos_resources = [r['name'] for r in resources]
    map(quotas.pop, filter(lambda k: k not in pithos_resources, quotas.keys()))
    return quotas.popitem()[-1] # assume only one resource
예제 #5
0
 def test_get_quotas(self):
     """Test function call of get_quotas"""
     global quotas, token, auth_url
     try:
         client = AstakosClient(token['id'], auth_url)
         result = client.get_quotas()
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     self.assertEqual(quotas, result)
예제 #6
0
파일: tests.py 프로젝트: AthinaB/synnefo
 def test_get_quotas(self):
     """Test function call of get_quotas"""
     global quotas, token, auth_url
     try:
         client = AstakosClient(token['id'], auth_url)
         result = client.get_quotas()
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     self.assertEqual(quotas, result)
예제 #7
0
 def test_get_quotas(self):
     """Test function call of get_quotas"""
     global quotas, token_1
     _mock_request([_request_ok])
     try:
         client = AstakosClient("https://example.com")
         result = client.get_quotas(token_1)
     except Exception as err:
         self.fail("Shouldn't raise Exception %s" % err)
     self.assertEqual(quotas, result)
예제 #8
0
def get_pithos_usage(token):
    """Get Pithos Usage from astakos."""
    astakos = AstakosClient(ASTAKOS_BASE_URL,
                            retry=2,
                            use_pool=True,
                            logger=logger)
    quotas = astakos.get_quotas(token)['system']
    pithos_resources = [r['name'] for r in resources]
    map(quotas.pop, filter(lambda k: k not in pithos_resources, quotas.keys()))
    return quotas.popitem()[-1]  # assume only one resource