Index: /main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_utils.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_utils.py	(revision 11820)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_utils.py	(revision 11821)
@@ -19,4 +19,5 @@
 ##
 import psutil
+import sys
 import unittest
 from waeup.kofa.interfaces import IKofaUtils
@@ -26,4 +27,9 @@
 
 class KofaUtilsTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.max_pmem = psutil.phymem_usage().total
+        self.max_vmem = psutil.virtual_memory().total
+        self.max_smem = psutil.swap_memory().total
 
     def get_cleared_util(self):
@@ -56,7 +62,11 @@
         # We can react to high swap values
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['swap-mem'] = 99.0    # positive number
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = 99.0           # positive float
         assert utils.expensive_actions_allowed() == True
-        utils.SYSTEM_MAX_LOAD['swap-mem'] = -1.0    # negative number
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = -1.0           # negative float
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = sys.maxint     # positive int
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = -1             # negative int
         assert utils.expensive_actions_allowed() == True
 
@@ -67,7 +77,11 @@
         # We can react if too much swap is used
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['swap-mem'] = 0.0     # positive number
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = 0.0            # positive float
         assert utils.expensive_actions_allowed() == False
-        utils.SYSTEM_MAX_LOAD['swap-mem'] = -100.0  # negative number
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = -100.0         # negative float
+        assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = 0              # positive int
+        assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['swap-mem'] = -(sys.maxint)  # negative int
         assert utils.expensive_actions_allowed() == False
 
@@ -87,7 +101,11 @@
         # We can react to high virtmem values
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['virt-mem'] = 99.0    # positive number
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = 99.0           # positive float
         assert utils.expensive_actions_allowed() == True
-        utils.SYSTEM_MAX_LOAD['virt-mem'] = -1.0    # negative number
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = -1.0           # negative float
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = sys.maxint     # positive int
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = -1             # negative int
         assert utils.expensive_actions_allowed() == True
 
@@ -98,7 +116,11 @@
         # We can react if too much virtmem is used
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['virt-mem'] = 0.0     # positive number
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = 0.0            # positive float
         assert utils.expensive_actions_allowed() == False
-        utils.SYSTEM_MAX_LOAD['virt-mem'] = -100.0  # negative number
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = -100.0         # negative float
+        assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = 0              # positive int
+        assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['virt-mem'] = -(sys.maxint)  # negative int
         assert utils.expensive_actions_allowed() == False
 
@@ -113,12 +135,17 @@
 
     @unittest.skipIf(
-        psutil.phymem_usage().percent >= 99.0,
+        psutil.phymem_usage().percent >= 99.99,
         reason="System physmem use over 99%. Cannot set higher allowed value.")
     def test_expensive_actions_allowed_physmem_ok(self):
         # We can react to high physmem values
+        max_mem = psutil.phymem_usage().total
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['phys-mem'] = 99.0    # positive number
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = 99.99          # positive float
         assert utils.expensive_actions_allowed() == True
-        utils.SYSTEM_MAX_LOAD['phys-mem'] = -1.0    # negative number
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = -0.01          # negative float
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = max_mem        # positive int
+        assert utils.expensive_actions_allowed() == True
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = -1             # negative int
         assert utils.expensive_actions_allowed() == True
 
@@ -128,7 +155,12 @@
     def test_expensive_actions_allowed_physmem_too_much(self):
         # We can react if too much physmem is used
+        max_mem = psutil.phymem_usage().total
         utils = self.get_cleared_util()
-        utils.SYSTEM_MAX_LOAD['phys-mem'] = 0.0     # positive number
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = 0.0            # positive float
         assert utils.expensive_actions_allowed() == False
-        utils.SYSTEM_MAX_LOAD['phys-mem'] = -100.0  # negative number
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = -100.0         # negative float
         assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = 0              # positive int
+        assert utils.expensive_actions_allowed() == False
+        utils.SYSTEM_MAX_LOAD['phys-mem'] = -(max_mem)     # negative int
+        assert utils.expensive_actions_allowed() == False
Index: /main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py	(revision 11820)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py	(revision 11821)
@@ -329,10 +329,12 @@
             if isinstance(max_val, float):
                 # percents
-                max_val %= 100.0
+                if max_val < 0.0:
+                    max_val = 100.0 + max_val
                 if mem_val.percent > max_val:
                     return False
             else:
                 # number of bytes
-                max_val %= mem_val.total
+                if max_val < 0:
+                    max_val = mem_val.total + max_val
                 if mem_val.used > max_val:
                     return False
