Commit 5dcad10f authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Import QH_PRACTICALLY_INFINITE in tests

parent 44dfc5ae
......@@ -38,6 +38,7 @@ from config import printf
from synnefo.lib.commissioning import CallError
from synnefo.lib.quotaholder.api import (
QH_PRACTICALLY_INFINITE,
InvalidDataError,
InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError,
......@@ -47,8 +48,6 @@ from synnefo.lib.quotaholder.api.quotaholder import (
Name, Key, Quantity, Capacity, ImportLimit, ExportLimit, Resource, Flags,
Imported, Exported, Returned, Released)
QH_MAX_INT = 10**32
DEFAULT_HOLDING = (0, 0, 0, 0)
class QHAPITest(QHTestCase):
......@@ -238,30 +237,35 @@ class QHAPITest(QHTestCase):
resource1 = self.rand_resource()
r = self.qh.set_quota(
set_quota=[(e0, resource0, k0) + (5, QH_MAX_INT, 5, 6) + (0,),
set_quota=[(e0, resource0, k0) + (5, QH_PRACTICALLY_INFINITE, 5, 6) + (0,),
(e1, resource0, k1) + (5, 5, 5, 5) + (0,)])
self.assertEqual(r, [])
r = self.qh.add_quota(clientkey=self.client,
serial=1,
sub_quota=[(e0, resource0, k0, 0, QH_MAX_INT, 1, 1)],
add_quota=[(e0, resource0, k0, 0, 3, QH_MAX_INT, 0),
sub_quota=[(e0, resource0, k0,
0, QH_PRACTICALLY_INFINITE, 1, 1)],
add_quota=[(e0, resource0, k0,
0, 3, QH_PRACTICALLY_INFINITE, 0),
# new holding
(e0, resource1, k0, 0, QH_MAX_INT, 5, 5)])
(e0, resource1, k0,
0, QH_PRACTICALLY_INFINITE, 5, 5)])
self.assertEqual(r, [])
r = self.qh.get_quota(get_quota=[(e0, resource0, k0),
(e0, resource1, k0)])
self.assertEqual(r, [(e0, resource0, 5, 3, QH_MAX_INT+4, 5)
self.assertEqual(r, [(e0, resource0, 5, 3, QH_PRACTICALLY_INFINITE+4, 5)
+ DEFAULT_HOLDING + (0,),
(e0, resource1, 0, QH_MAX_INT, 5, 5)
(e0, resource1, 0, QH_PRACTICALLY_INFINITE, 5, 5)
+ DEFAULT_HOLDING + (0,)])
# repeated serial
r = self.qh.add_quota(clientkey=self.client,
serial=1,
sub_quota=[(e0, resource1, k0, 0, QH_MAX_INT, (-5), 0)],
add_quota=[(e0, resource0, k0, 0, 2, QH_MAX_INT, 0)])
sub_quota=[(e0, resource1, k0,
0, QH_PRACTICALLY_INFINITE, (-5), 0)],
add_quota=[(e0, resource0, k0,
0, 2, QH_PRACTICALLY_INFINITE, 0)])
self.assertEqual(r, [(e0, resource1), (e0, resource0)])
r = self.qh.query_serials(clientkey=self.client, serials=[1, 2])
......@@ -284,13 +288,15 @@ class QHAPITest(QHTestCase):
# serial has been deleted
r = self.qh.add_quota(clientkey=self.client,
serial=1,
add_quota=[(e0, resource0, k0, 0, 2, QH_MAX_INT, 0)])
add_quota=[(e0, resource0, k0,
0, 2, QH_PRACTICALLY_INFINITE, 0)])
self.assertEqual(r, [])
# none is committed
r = self.qh.add_quota(clientkey=self.client,
serial=2,
add_quota=[(e1, resource0, k1, 0, (-10), QH_MAX_INT, 0),
add_quota=[(e1, resource0, k1,
0, (-10), QH_PRACTICALLY_INFINITE, 0),
(e0, resource1, k0, 1, 0, 0, 0)])
self.assertEqual(r, [(e1, resource0)])
......@@ -298,7 +304,7 @@ class QHAPITest(QHTestCase):
(e0, resource1, k0)])
self.assertEqual(r, [(e1, resource0, 5, 5 , 5, 5)
+ DEFAULT_HOLDING + (0,),
(e0, resource1, 0, QH_MAX_INT, 5, 5)
(e0, resource1, 0, QH_PRACTICALLY_INFINITE, 5, 5)
+ DEFAULT_HOLDING + (0,)])
def test_0082_max_quota(self):
......@@ -308,17 +314,19 @@ class QHAPITest(QHTestCase):
resource1 = self.rand_resource()
r = self.qh.set_quota(
set_quota=[(e0, resource0, k0) + (5, QH_MAX_INT, 5, 6) + (0,)])
set_quota=[(e0, resource0, k0) +
(5, QH_PRACTICALLY_INFINITE, 5, 6) + (0,)])
self.assertEqual(r, [])
r = self.qh.add_quota(clientkey=self.client,
serial=3,
add_quota=[(e0, resource0, k0, 0, QH_MAX_INT, 0, 0)])
add_quota=[(e0, resource0, k0,
0, QH_PRACTICALLY_INFINITE, 0, 0)])
self.assertEqual(r, [])
r = self.qh.get_quota(get_quota=[(e0, resource0, k0)])
self.assertEqual(r, [(e0, resource0, 5, 2*QH_MAX_INT, 5, 6)
self.assertEqual(r, [(e0, resource0, 5, 2*QH_PRACTICALLY_INFINITE, 5, 6)
+ DEFAULT_HOLDING + (0,)])
......@@ -422,9 +430,15 @@ class QHAPITest(QHTestCase):
if r:
raise AssertionError("cannot create entities")
self.qh.set_quota(set_quota=[(sys, resource, '', 10, 0, QH_MAX_INT, QH_MAX_INT, 0),
(e0, resource, k0, 0, 10, QH_MAX_INT, QH_MAX_INT, 0),
(e1, resource, k1, 0, 10, QH_MAX_INT, QH_MAX_INT, 0)])
self.qh.set_quota(set_quota=[(sys, resource, '', 10, 0,
QH_PRACTICALLY_INFINITE,
QH_PRACTICALLY_INFINITE, 0),
(e0, resource, k0, 0, 10,
QH_PRACTICALLY_INFINITE,
QH_PRACTICALLY_INFINITE, 0),
(e1, resource, k1, 0, 10,
QH_PRACTICALLY_INFINITE,
QH_PRACTICALLY_INFINITE, 0)])
s0 = self.qh.issue_commission(clientkey=self.client, target=e0, key=k0,
name='a commission',
......
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