[953] | 1 |
|
---|
| 2 | # $Id: unittests.py 10982 2010-09-15 11:02:25Z pstorz $
|
---|
| 3 |
|
---|
| 4 | import logging
|
---|
| 5 | logging.basicConfig(level=logging.ERROR,
|
---|
| 6 | format='%(asctime)s %(levelname)s \t (%(module)s:%(lineno)d) %(message)s ',
|
---|
| 7 | #filename='vanHelsing.log',
|
---|
| 8 | filemode='w')
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | import nosferatu.bacresources as bacresources
|
---|
| 13 | import unittest
|
---|
| 14 |
|
---|
| 15 | class TestSequenceFunctions(unittest.TestCase):
|
---|
| 16 |
|
---|
| 17 | def setUp(self):
|
---|
| 18 | configstring = open('regression/bacula-dir.conf.bruno').read()
|
---|
| 19 | self.DirConf = bacresources.DirectorConfig(configstring)
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | def test_getname(self):
|
---|
| 23 | # check the getName function on Director Config
|
---|
| 24 | self.name = self.DirConf.getName()
|
---|
| 25 | self.assertEqual(self.name, 'bacula-dir')
|
---|
| 26 |
|
---|
| 27 | def test_getResourcesListByResType(self):
|
---|
| 28 | for res in self.DirConf.validresourcesset:
|
---|
| 29 | print res, len(self.DirConf.getResourcesListByResType(res))
|
---|
| 30 |
|
---|
| 31 | def test_getResourceByName(self):
|
---|
| 32 | print "starting test_getResourceByName"
|
---|
| 33 | for name in ['Standard', 'rt-message', 'Daemon', 'Default',
|
---|
| 34 | 'Scratch', 'LTO4Pool', 'Archive', 'FileStoragePool',
|
---|
| 35 | 'TestPool', 'VMImage-Pool', 'Export-VMImage-Pool',
|
---|
| 36 | 'Export-Server-Pool', 'bacula-mon', 'python','WeeklyCycleAfterBackup','ServerJob']:
|
---|
| 37 | print name, self.DirConf.getResourceByName(name).__class__.__name__
|
---|
| 38 | #print self.DirConf.getResourceByName(name)
|
---|
| 39 |
|
---|
| 40 | def test_getReferencingResourcesListForResource(self):
|
---|
| 41 | print "starting test_getReferencingResourcesListForResource"
|
---|
| 42 | for res in self.DirConf.resources:
|
---|
| 43 | #name = res.items_dict['name'].storage.value
|
---|
| 44 | #print name
|
---|
| 45 | # for name in ['Standard', 'rt-message', 'Daemon', 'Default',
|
---|
| 46 | #'Scratch', 'LTO4Pool', 'Archive', 'FileStoragePool',
|
---|
| 47 | #'TestPool', 'VMImage-Pool', 'Export-VMImage-Pool',
|
---|
| 48 | #'Export-Server-Pool', 'bacula-mon', 'python','WeeklyCycleAfterBackup']:
|
---|
| 49 | #print name, self.DirConf.getResourceByName(name).__class__.__name__
|
---|
| 50 | #res = self.DirConf.getResourceByName(name)
|
---|
| 51 | reflist = self.DirConf.getReferencingResourcesListForResource(res)
|
---|
| 52 | #print '\n',res.resourcetype, res.items_dict['name'].storage.value,"is referenced", len(reflist),"times:"
|
---|
| 53 | for refres in reflist:
|
---|
| 54 | #print refres.resourcetype, refres.items_dict['name'].storage.value
|
---|
| 55 | print '"'+refres.resourcetype , str(refres.items_dict['name'].storage.value).strip('"') + '"->"' + res.resourcetype,str(res.items_dict['name'].storage.value).strip('"') + '"'
|
---|
| 56 | # print res.items_dict['name'], len(self.DirConf.getReferencingResourcesListForResource(res))
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | #def test_onlineHelp(self):
|
---|
| 60 | # print "starting test_onlineHelp"
|
---|
| 61 | # for res in self.DirConf.resources:
|
---|
| 62 | # print res.items_dict['name'].storage.value,res.onlinehelpURL
|
---|
| 63 | #def test_selfcheck(self):
|
---|
| 64 | # pass
|
---|
| 65 |
|
---|
| 66 | #def test_createResource(self):
|
---|
| 67 | # pass
|
---|
| 68 |
|
---|
| 69 | # def test_sample(self):
|
---|
| 70 | # self.assertRaises(ValueError, random.sample, self.seq, 20)
|
---|
| 71 | # for element in random.sample(self.seq, 5):
|
---|
| 72 | # self.assertTrue(element in self.seq)
|
---|
| 73 |
|
---|
| 74 | if __name__ == '__main__':
|
---|
| 75 | unittest.main()
|
---|
| 76 |
|
---|