9 from mic import conf, msger
10 from pykickstart.parser import KickstartParser
12 CWD = os.path.dirname(__file__) or '.'
13 SITECONF = os.path.join(CWD, 'configmgr_fixtures', 'mic.conf')
14 KSCONF = os.path.join(CWD, 'configmgr_fixtures', 'test.ks')
15 KSBAK = os.path.join(CWD, 'configmgr_fixtures', 'test.ks.bak')
16 REPOURI = os.path.join(CWD, 'configmgr_fixtures', 'packages')
17 CACHEDIR = os.path.join(CWD, 'configmgr_fixtures', 'cache')
20 return unittest.makeSuite(ConfigMgrTest)
22 class ConfigMgrTest(unittest.TestCase):
25 self.configmgr = conf.ConfigMgr(siteconf=SITECONF)
26 shutil.copy2(KSCONF, KSBAK)
27 with open(KSCONF, 'r') as f:
29 content = content.replace('$$$$$$', "file://" + REPOURI)
30 with open(KSCONF, 'w') as f:
32 if not os.path.exists(CACHEDIR):
34 self.configmgr.create['cachedir'] = CACHEDIR
35 self.level = msger.get_loglevel()
36 msger.set_loglevel('RAWTEXT')
39 msger.set_loglevel(self.level)
40 shutil.copy2(KSBAK, KSCONF)
42 shutil.rmtree(CACHEDIR, ignore_errors = True)
44 # def testCommonSection(self):
45 # self.assertEqual(self.configmgr.common['test'], 'test')
47 def testCreateSection(self):
48 #self.assertEqual(self.configmgr.create['local_pkgs_path'], '/opt/cache')
49 self.assertEqual(self.configmgr.create['pkgmgr'], 'yum')
51 # def testChrootSection(self):
52 # self.assertEqual(self.configmgr.chroot['test2'], 'test2')
54 # def testConvertSection(self):
55 # self.assertEqual(self.configmgr.convert['test3'], 'test3')
57 def testKickstartConfig(self):
58 cachedir = self.configmgr.create['cachedir']
59 repomd = [{'baseurl': 'file://%s' % REPOURI ,
60 'cachedir': '%s' % cachedir,
64 'primary': '%s/test/primary.sqlite' % cachedir,
67 'repomd': '%s/test/repomd.xml' % cachedir,
69 self.configmgr._ksconf = KSCONF
70 self.assertTrue(isinstance(self.configmgr.create['ks'], KickstartParser))
71 #self.assertEqual(self.configmgr.create['name'], 'test')
72 #self.assertDictEqual(repomd[0], self.configmgr.create['repomd'][0])
73 self.assertEqual(repomd[0], self.configmgr.create['repomd'][0])
74 self.assertEqual(self.configmgr.create['arch'], 'i686')
76 if __name__ == "__main__":