fix bug in bucket checker; fix enforcer test case
smbaker [Thu, 1 Nov 2012 00:08:04 +0000 (17:08 -0700)]
apps/gacks/gacksenforce.py
apps/gacks/gacksenforce_test.py

index 9ea2d07..1151b6e 100644 (file)
@@ -85,7 +85,7 @@ class GacksEnforcer:
         print "check_bucket"
 
         # load and/or initialize the bucket
-        bucketAccount = self.accounts.get_account(hrn_to_gacksid(account.name), "bucket", create_if_not_exist=True)
+        bucketAccount = self.accounts.get_account(hrn_to_gacksid(name), "bucket", create_if_not_exist=True)
         bucketAccount.inRate = policy.bucketInRate
         bucketAccount.maxBalance = policy.bucketMax
         if (bucketAccount.created):
index 598586c..4423c10 100644 (file)
@@ -8,6 +8,7 @@ from gacksenforce import GacksEnforcer
 from gackspolicy import GacksPolicyDirectory
 from gackshandle import GacksHandle, GacksRecord
 from gacksexcep import *
+from gacksid import *
 
 HOUR=60*60
 DAY=24*60*60
@@ -53,52 +54,52 @@ class test:
 
     def init_accounts(self):
         # initialize some accounts
-        self.accounts.delete_account("plc.test.gold", "user")
-        self.accounts.delete_account("plc.test.silver", "user")
-        self.accounts.delete_account("plc.test.best", "user")
-        self.accounts.delete_account("plc.test.test1", "user")
-        self.accounts.delete_account("plc.test.test1b", "user")
-        self.accounts.delete_account("plc.test.test1c", "user")
-        self.accounts.delete_account("plc.test.test1d", "user")
-        self.accounts.delete_account("plc.test.test2", "user")
-        self.accounts.delete_account("plc.test.test2", "bucket")
-
-        self.gold=self.accounts.new_account("plc.test.gold", "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.gold"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.silver"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.best"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test1"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test1b"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test1c"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test1d"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test2"), "user")
+        self.accounts.delete_account(hrn_to_gacksid("plc.test.test2"), "bucket")
+
+        self.gold=self.accounts.new_account(hrn_to_gacksid("plc.test.gold"), "user")
         self.gold.level="gold"
         self.gold.goodStanding=True
         self.gold.commit()
 
-        self.silver=self.accounts.new_account("plc.test.silver", "user")
+        self.silver=self.accounts.new_account(hrn_to_gacksid("plc.test.silver"), "user")
         self.silver.level="silver"
         self.silver.goodStanding=True
         self.silver.commit()
 
-        self.best=self.accounts.new_account("plc.test.best", "user")
+        self.best=self.accounts.new_account(hrn_to_gacksid("plc.test.best"), "user")
         self.best.goodStanding=True
         self.best.commit()
 
-        self.test1=self.accounts.new_account("plc.test.test1", "user")
+        self.test1=self.accounts.new_account(hrn_to_gacksid("plc.test.test1"), "user")
         self.test1.level="test_policy_1"
         self.test1.goodStanding=True
         self.test1.commit()
 
-        self.test1b=self.accounts.new_account("plc.test.test1b", "user")
+        self.test1b=self.accounts.new_account(hrn_to_gacksid("plc.test.test1b"), "user")
         self.test1b.level="test_policy_1"
         self.test1b.goodStanding=True
         self.test1b.commit()
 
-        self.test1c=self.accounts.new_account("plc.test.test1c", "user")
+        self.test1c=self.accounts.new_account(hrn_to_gacksid("plc.test.test1c"), "user")
         self.test1c.level="test_policy_1"
         self.test1c.multiplier=2
         self.test1c.goodStanding=True
         self.test1c.commit()
 
-        self.test1d=self.accounts.new_account("plc.test.test1d", "user")
+        self.test1d=self.accounts.new_account(hrn_to_gacksid("plc.test.test1d"), "user")
         self.test1d.level="test_policy_1"
         self.test1d.goodStanding=False
         self.test1d.commit()
 
-        self.test2=self.accounts.new_account("plc.test.test2", "user")
+        self.test2=self.accounts.new_account(hrn_to_gacksid("plc.test.test2"), "user")
         self.test2.level="test_policy_2"
         self.test2.goodStanding=True
         self.test2.commit()
@@ -337,7 +338,7 @@ class test:
         except GacksEnforcerBucketUnderflow:
             pass
         else:
-            raise "Failed to raise GacksEnforcerBuckerUnderflow"
+            raise "Failed to raise GacksEnforcerBucketUnderflow"
 
         h5 = GacksHandle(id="plc.vicci.cores", timeStart=t+HOUR, timeStop=t+2*HOUR, unitStart=NODE4, unitStop=NODE4+1)
         try:
@@ -345,7 +346,7 @@ class test:
         except GacksEnforcerBucketUnderflow:
             pass
         else:
-            raise "Failed to raise GacksEnforcerBuckerUnderflow"
+            raise "Failed to raise GacksEnforcerBucketUnderflow"
 
         h5 = GacksHandle(id="plc.vicci.cores", timeStart=t+2*HOUR, timeStop=t+3*HOUR, unitStart=NODE4, unitStop=NODE4+1)
         try:
@@ -353,7 +354,7 @@ class test:
         except GacksEnforcerBucketUnderflow:
             pass
         else:
-            raise "Failed to raise GacksEnforcerBuckerUnderflow"
+            raise "Failed to raise GacksEnforcerBucketUnderflow"
 
         # try some long reservations