Beispiel #1
0
    def setUp(self):
        if configtools.config == None:
            log.debug("Doing configuration bits...")
            self.cfgdir = os.path.join(os.path.dirname(__file__),
                                       'testconfig/')
            configtools.config = configtools.Configuration(self.cfgdir)

        self.cfg = configtools.config

        self.p1 = MetaParser(self.getFile('meta1'))
        self.p2 = MetaParser(self.getFile('meta2'))
        self.p3 = MetaParser(self.getFile('meta3'))
Beispiel #2
0
class TestMetaParser(unittest.TestCase):

    def getFile(self, test):
        return os.path.join(self.cfg.hosts, test)

    def setUp(self):
        if configtools.config == None:
            log.debug("Doing configuration bits...")
            self.cfgdir = os.path.join(os.path.dirname(__file__),
                                       'testconfig/')
            configtools.config = configtools.Configuration(self.cfgdir)

        self.cfg = configtools.config

        self.p1 = MetaParser(self.getFile('meta1'))
        self.p2 = MetaParser(self.getFile('meta2'))
        self.p3 = MetaParser(self.getFile('meta3'))

    def testEquality(self):
        self.assert_(self.p1 != self.p2)
        self.assert_(self.p2 == self.p2)

    def testIsKickstart(self):
        self.assert_(not self.p1.isKickstart())
        self.assert_(    self.p3.isKickstart())

    def testGetCommands(self):
        self.assert_(self.p1.filecommands == ['foo bar', 'bar baz'])
        self.assert_(self.p2.filecommands == ['owner [email protected]',
                                              'use meta2.5'])

        cmd = '\n'.join(self.p1.filecommands)
        self.assert_(self.p1.getCommands() == cmd)

    def testPosts(self):
        posts1 = ['%post\n\n# Post Script\n\n']
        posts2 = ['%post --interpreter /usr/bin/python\n\nprint "Hello World"\n\n', '%post\n\n# Post Script\n\n    date > /.install-date\n']
        
        self.assertEquals(self.p1.getPosts(), posts1)
        self.assertEquals(self.p2.getPosts(), posts2)

    def testVersion(self):
        self.assertNotEqual(configtools.config, None)
        log.debug("hosts = " + configtools.config.hosts)
        self.assert_(self.p1.getVersion(profileKey='foo', includeKey='use') \
                     == 'bar')
        self.assert_(self.p2.getVersion(profileKey='foo', includeKey='use') \
                     == 'sue')