Changeset 8517 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 25 May 2012, 02:02:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_datacenter.py
r8514 r8517 13 13 14 14 15 class DataCenterTests(unittest.TestCase): 15 class DataCenterLogQueryTests(unittest.TestCase): 16 # Tests for querying logfiles via datacenter. 16 17 17 18 def setUp(self): … … 50 51 return 51 52 52 def test_iface(self):53 # we comply with interfaces54 obj = DataCenter()55 verifyClass(IDataCenter, DataCenter)56 verifyObject(IDataCenter, obj)57 return58 59 53 def test_query_logfiles(self): 60 54 # We can find entries in logfiles … … 164 158 self.assertEqual(result[0], 'Msg 1\n') 165 159 return 160 161 class DataCenterTests(unittest.TestCase): 162 # General datacenter tests. 163 164 def setUp(self): 165 # create a temporary place to store files 166 self.workdir = tempfile.mkdtemp() 167 self.storage = os.path.join(self.workdir, 'storage') 168 os.mkdir(self.storage) 169 self.logpath = os.path.join(self.storage, 'logs', 'myapp.log') 170 # register a datacenter config that provides the set up location 171 self.config = {'path': self.storage,} 172 self.gsm = getGlobalSiteManager() 173 self.gsm.registerUtility(self.config, IDataCenterConfig) 174 pass 175 176 def tearDown(self): 177 self.gsm.unregisterUtility(self.config, IDataCenterConfig) 178 shutil.rmtree(self.workdir) 179 return 180 181 def test_iface(self): 182 # we comply with interfaces 183 obj = DataCenter() 184 verifyClass(IDataCenter, DataCenter) 185 verifyObject(IDataCenter, obj) 186 return 187 188 def test_get_log_files(self): 189 # We can get lists of logfiles available. 190 # By default, backups are skipped. 191 datacenter = DataCenter() 192 logpath2 = self.logpath + '.1' 193 logpath3 = self.logpath + '.2' 194 for path in self.logpath, logpath2, logpath3: 195 open(path, 'wb').write('some contents') 196 result = datacenter.getLogFiles() 197 self.assertEqual(len(result), 1) 198 self.assertEqual(result[0].name, os.path.basename(self.logpath)) 199 return 200 201 def test_get_log_files_incl_backups(self): 202 # We can get lists of logfiles including backup logs. 203 datacenter = DataCenter() 204 logpath2 = self.logpath + '.1' 205 logpath3 = self.logpath + '.2' 206 for path in self.logpath, logpath2, logpath3: 207 open(path, 'wb').write('some contents') 208 result = datacenter.getLogFiles(exclude_backups=False) 209 self.assertEqual(len(result), 3) 210 names = [x.name for x in result] 211 expected = [os.path.basename(x) for x in [ 212 self.logpath, logpath2, logpath3]] 213 self.assertEqual(names, expected) 214 return
Note: See TracChangeset for help on using the changeset viewer.