1 |
|
---|
2 | # $Id: unittests.py 11429 2010-11-01 18:31:49Z 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 | import os
|
---|
15 |
|
---|
16 | class TestSequenceFunctions(unittest.TestCase):
|
---|
17 |
|
---|
18 | def setUp(self):
|
---|
19 | '''
|
---|
20 | setup our test configuration
|
---|
21 | '''
|
---|
22 | self.dc = bacresources.DataCenter('regression/dassIT.dmdz')
|
---|
23 | print os.getcwdu()
|
---|
24 | #configstring = open('regression/bacula-dir.conf').read()
|
---|
25 | #self.DirConf = bacresources.DirectorConfig(configstring)
|
---|
26 | self.DirConf = self.dc.directors.pop()
|
---|
27 |
|
---|
28 | print 'cwd: ' + os.getcwd()
|
---|
29 |
|
---|
30 | def test_importConfigurationFile(self):
|
---|
31 | '''
|
---|
32 | try importing a configuration file into a datacenter
|
---|
33 | '''
|
---|
34 | self.dc.importConfigurationFile('regression/bacula-fd-import.conf', 'filedaemon')
|
---|
35 | print self.dc
|
---|
36 | for fd in self.dc.filedaemons:
|
---|
37 | print fd
|
---|
38 |
|
---|
39 |
|
---|
40 | def test_getname(self):
|
---|
41 | # check the getName function on Director Config
|
---|
42 | self.name = self.DirConf.getName()
|
---|
43 | self.assertEqual(self.name, 'bacula-dir')
|
---|
44 |
|
---|
45 | def test_getResourcesListByResType(self):
|
---|
46 | for res in self.DirConf.validresourcesset:
|
---|
47 | print res, len(self.DirConf.getResourcesListByResType(res))
|
---|
48 |
|
---|
49 | def test_getResourceByName(self):
|
---|
50 | print "starting test_getResourceByName"
|
---|
51 | for name in ['Standard', 'rt-message', 'Daemon', 'Default',
|
---|
52 | 'Scratch', 'LTO4Pool', 'Archive', 'FileStoragePool',
|
---|
53 | 'TestPool', 'VMImage-Pool', 'Export-VMImage-Pool',
|
---|
54 | 'Export-Server-Pool', 'bacula-mon', 'python','WeeklyCycleAfterBackup','ServerJob']:
|
---|
55 | print name, self.DirConf.getResourceByName(name).__class__.__name__
|
---|
56 | #print self.DirConf.getResourceByName(name)
|
---|
57 |
|
---|
58 | def test_getReferencingResourcesListForResource(self):
|
---|
59 | print "starting test_getReferencingResourcesListForResource"
|
---|
60 | for res in self.DirConf.resources:
|
---|
61 | #name = res.items_dict['name'].storage.value
|
---|
62 | #print name
|
---|
63 | # for name in ['Standard', 'rt-message', 'Daemon', 'Default',
|
---|
64 | #'Scratch', 'LTO4Pool', 'Archive', 'FileStoragePool',
|
---|
65 | #'TestPool', 'VMImage-Pool', 'Export-VMImage-Pool',
|
---|
66 | #'Export-Server-Pool', 'bacula-mon', 'python','WeeklyCycleAfterBackup']:
|
---|
67 | #print name, self.DirConf.getResourceByName(name).__class__.__name__
|
---|
68 | #res = self.DirConf.getResourceByName(name)
|
---|
69 | reflist = self.DirConf.getReferencingResourcesListForResource(res)
|
---|
70 | print '\n',res.resourcetype, res.items_dict['name'].storage.value,"is referenced", len(reflist),"times:"
|
---|
71 | for refres in reflist:
|
---|
72 | print refres.resourcetype, refres.items_dict['name'].storage.value
|
---|
73 | #print '"'+refres.resourcetype , str(refres.items_dict['name'].storage.value).strip('"') + '"->"' + res.resourcetype,str(res.items_dict['name'].storage.value).strip('"') + '"'
|
---|
74 | # print res.items_dict['name'], len(self.DirConf.getReferencingResourcesListForResource(res))
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 | def test_onlineHelp(self):
|
---|
80 | print "starting test_onlineHelp"
|
---|
81 | for res in self.DirConf.resources:
|
---|
82 | print res.items_dict['name'].storage.value,res.onlinehelpURL
|
---|
83 | #def test_selfcheck(self):
|
---|
84 | # pass
|
---|
85 |
|
---|
86 | #def test_createResource(self):
|
---|
87 | # pass
|
---|
88 |
|
---|
89 | # def test_sample(self):
|
---|
90 | # self.assertRaises(ValueError, random.sample, self.seq, 20)
|
---|
91 | # for element in random.sample(self.seq, 5):
|
---|
92 | # self.assertTrue(element in self.seq)
|
---|
93 |
|
---|
94 | if __name__ == '__main__':
|
---|
95 | unittest.main()
|
---|
96 |
|
---|