diff src/test/test_memory.py @ 786:c3acc1298a2f

test: FakeMemory inherits from Memory + more helpers basic support + cleaning
author souliane <souliane@mailoo.org>
date Sun, 05 Jan 2014 13:04:54 +0100
parents 0e5807193721
children 0cb423500fbb
line wrap: on
line diff
--- a/src/test/test_memory.py	Sun Jan 05 13:00:17 2014 +0100
+++ b/src/test/test_memory.py	Sun Jan 05 13:04:54 2014 +0100
@@ -92,6 +92,11 @@
         """@param src: a deferred result from Memory.getParams"""
         self._assert(src, False)
 
+    def _getParams(self, security_limit, app='', profile_key='@NONE@'):
+        if profile_key == '@NONE@':
+            profile_key = '@DEFAULT@'
+        return self.host.memory.getParams(security_limit, app, profile_key)
+
     def test_updateParams(self):
         self.host.memory.init()
         # check if the update works
@@ -107,23 +112,23 @@
         params = self._getParamXML()
         self.host.memory.init()
         self.host.memory.updateParams(params)
-        self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
-        self.host.memory.getParams(0, app='').addCallback(self._assert_not)
-        self.host.memory.getParams(1, app='').addCallback(self._assert_not)
+        self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
+        self._getParams(0).addCallback(self._assert_not)
+        self._getParams(1).addCallback(self._assert_not)
         # tests with security level 0 on the parameter (not secure)
         params = self._getParamXML(security_level=0)
         self.host.memory.init()
         self.host.memory.updateParams(params)
-        self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
-        self.host.memory.getParams(0, app='').addCallback(self._assert)
-        self.host.memory.getParams(1, app='').addCallback(self._assert)
+        self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
+        self._getParams(0).addCallback(self._assert)
+        self._getParams(1).addCallback(self._assert)
         # tests with security level 1 on the parameter (more secure)
         params = self._getParamXML(security_level=1)
         self.host.memory.init()
         self.host.memory.updateParams(params)
-        self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
-        self.host.memory.getParams(0).addCallback(self._assert_not)
-        self.host.memory.getParams(1).addCallback(self._assert)
+        self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
+        self._getParams(0).addCallback(self._assert_not)
+        self._getParams(1).addCallback(self._assert)
 
     def test_paramsRegisterApp(self):
         # tests with no security level on the parameter (most secure)
@@ -165,6 +170,6 @@
         self.host.memory.init()
         params = self._getParamXML(security_level=1)
         self.host.memory.paramsRegisterApp(params, 1, Const.APP_NAME)
-        self.host.memory.getParams(1, '').addCallback(self._assert)
-        self.host.memory.getParams(1, Const.APP_NAME).addCallback(self._assert)
-        self.host.memory.getParams(1, 'another_dummy_frontend').addCallback(self._assert_not)
+        self._getParams(1, '').addCallback(self._assert)
+        self._getParams(1, Const.APP_NAME).addCallback(self._assert)
+        self._getParams(1, 'another_dummy_frontend').addCallback(self._assert_not)