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")
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")
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")
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
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)
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)
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)
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