Commit df319066 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

astakosclient: Create function issue_one_commission

Refs #3440
parent 4b6ef8d6
......@@ -355,6 +355,44 @@ class AstakosClient():
raise AstakosClientException(m)
def issue_one_commission(self, token, holder, source, provisions,
force=False, auto_accept=False):
"""Issue one commission (with specific holder and source)
keyword arguments:
token -- service's token (string)
holder -- user's id (string)
source -- commission's source (ex system) (string)
provisions -- resources with their quantity (list of (string, int))
force -- force this commission (boolean)
auto_accept -- auto accept this commission (boolean)
In case of success return commission's id (int).
Otherwise raise an AstakosClientException.
(See also issue_commission)
check_input("issue_one_commission", self.logger,
holder=holder, source=source,
request = {}
request["force"] = force
request["auto_accept"] = auto_accept
request["provisions"] = []
for p in provisions:
resource = p[0]
quantity = p[1]
t = {"holder": holder, "source": source,
"resource": resource, "quantity": quantity}
except Exception as err:
raise BadValue(str(err))
return self.issue_commission(token, request)
# ----------------------------------
# GET "/astakos/api/commissions"
def get_pending_commissions(self, token):
......@@ -915,7 +915,7 @@ class TestCommissions(unittest.TestCase):
# ----------------------------------
def test_issue_commission(self):
"""Test function call of issue_commission_core"""
"""Test function call of issue_commission"""
global token_1, commission_request, commission_successful_reqsponse
......@@ -927,7 +927,7 @@ class TestCommissions(unittest.TestCase):
# ----------------------------------
def test_issue_commission_quota_limit(self):
"""Test function call of issue_commission_core with limit exceeded"""
"""Test function call of issue_commission with limit exceeded"""
global token_1, commission_request, commission_failure_response
new_request = dict(commission_request)
......@@ -942,6 +942,20 @@ class TestCommissions(unittest.TestCase):
else:"Should have raised QuotaLimit Exception")
# ----------------------------------
def test_issue_one_commission(self):
"""Test function call of issue_one_commission"""
global token_1, commission_successful_response
client = AstakosClient("")
response = client.issue_one_commission(
token_1, "c02f315b-7d84-45bc-a383-552a3f97d2ad",
"system", [("cyclades.vm", 1), ("cyclades.ram", 30000)])
except Exception as err:"Shouldn't have raised Exception %s" % err)
self.assertEqual(response, commission_successful_response['serial'])
# ----------------------------------
def test_get_pending_commissions(self):
"""Test function call of get_pending_commissions"""
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