comparison 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
comparison
equal deleted inserted replaced
785:ff9a52077b36 786:c3acc1298a2f
90 90
91 def _assert_not(self, src): 91 def _assert_not(self, src):
92 """@param src: a deferred result from Memory.getParams""" 92 """@param src: a deferred result from Memory.getParams"""
93 self._assert(src, False) 93 self._assert(src, False)
94 94
95 def _getParams(self, security_limit, app='', profile_key='@NONE@'):
96 if profile_key == '@NONE@':
97 profile_key = '@DEFAULT@'
98 return self.host.memory.getParams(security_limit, app, profile_key)
99
95 def test_updateParams(self): 100 def test_updateParams(self):
96 self.host.memory.init() 101 self.host.memory.init()
97 # check if the update works 102 # check if the update works
98 self.host.memory.updateParams(self._getParamXML()) 103 self.host.memory.updateParams(self._getParamXML())
99 assert(self._paramExists()) 104 assert(self._paramExists())
105 def test_getParams(self): 110 def test_getParams(self):
106 # tests with no security level on the parameter (most secure) 111 # tests with no security level on the parameter (most secure)
107 params = self._getParamXML() 112 params = self._getParamXML()
108 self.host.memory.init() 113 self.host.memory.init()
109 self.host.memory.updateParams(params) 114 self.host.memory.updateParams(params)
110 self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert) 115 self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
111 self.host.memory.getParams(0, app='').addCallback(self._assert_not) 116 self._getParams(0).addCallback(self._assert_not)
112 self.host.memory.getParams(1, app='').addCallback(self._assert_not) 117 self._getParams(1).addCallback(self._assert_not)
113 # tests with security level 0 on the parameter (not secure) 118 # tests with security level 0 on the parameter (not secure)
114 params = self._getParamXML(security_level=0) 119 params = self._getParamXML(security_level=0)
115 self.host.memory.init() 120 self.host.memory.init()
116 self.host.memory.updateParams(params) 121 self.host.memory.updateParams(params)
117 self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert) 122 self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
118 self.host.memory.getParams(0, app='').addCallback(self._assert) 123 self._getParams(0).addCallback(self._assert)
119 self.host.memory.getParams(1, app='').addCallback(self._assert) 124 self._getParams(1).addCallback(self._assert)
120 # tests with security level 1 on the parameter (more secure) 125 # tests with security level 1 on the parameter (more secure)
121 params = self._getParamXML(security_level=1) 126 params = self._getParamXML(security_level=1)
122 self.host.memory.init() 127 self.host.memory.init()
123 self.host.memory.updateParams(params) 128 self.host.memory.updateParams(params)
124 self.host.memory.getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert) 129 self._getParams(Const.NO_SECURITY_LIMIT).addCallback(self._assert)
125 self.host.memory.getParams(0).addCallback(self._assert_not) 130 self._getParams(0).addCallback(self._assert_not)
126 self.host.memory.getParams(1).addCallback(self._assert) 131 self._getParams(1).addCallback(self._assert)
127 132
128 def test_paramsRegisterApp(self): 133 def test_paramsRegisterApp(self):
129 # tests with no security level on the parameter (most secure) 134 # tests with no security level on the parameter (most secure)
130 params = self._getParamXML() 135 params = self._getParamXML()
131 self.host.memory.init() 136 self.host.memory.init()
163 def test_paramsRegisterApp_getParams(self): 168 def test_paramsRegisterApp_getParams(self):
164 # test retrieving the parameter for a specific frontend 169 # test retrieving the parameter for a specific frontend
165 self.host.memory.init() 170 self.host.memory.init()
166 params = self._getParamXML(security_level=1) 171 params = self._getParamXML(security_level=1)
167 self.host.memory.paramsRegisterApp(params, 1, Const.APP_NAME) 172 self.host.memory.paramsRegisterApp(params, 1, Const.APP_NAME)
168 self.host.memory.getParams(1, '').addCallback(self._assert) 173 self._getParams(1, '').addCallback(self._assert)
169 self.host.memory.getParams(1, Const.APP_NAME).addCallback(self._assert) 174 self._getParams(1, Const.APP_NAME).addCallback(self._assert)
170 self.host.memory.getParams(1, 'another_dummy_frontend').addCallback(self._assert_not) 175 self._getParams(1, 'another_dummy_frontend').addCallback(self._assert_not)