summaryrefslogtreecommitdiffstats
path: root/tests/kickstart_test/commands_test.py
blob: 6fce53cd9143d62329b3af8107dc6f4d62648050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python
#
# Copyright (C) 2010  Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Chris Lumens <clumens@redhat.com>
import unittest
import sys
from mock import Mock, patch, TestCase, acceptance

class O(object):
    pass

# Verify that each kickstart command in anaconda uses the correct version of
# that command as provided by pykickstart.  That is, if there's an FC3 and an
# F10 version of a command, make sure anaconda >= F10 uses the F10 version.
class CommandVersionTestCase(TestCase):
    def setUp(self):
        self.setupModules([
            'pyanaconda.isys',
            'pyanaconda.storage',
            'pyanaconda.storage.isys',
            'pyanaconda.storage.devices',
            'pyanaconda.storage.formats',
            'pyanaconda.storage.partitioning',
            'pyanaconda.storage.deviceaction',
            'pyanaconda.storage.devicelibs',
            'pyanaconda.storage.devicelibs.lvm',
            'pyanaconda.storage.iscsi',
            'pyanaconda.storage.fcoe',
            'pyanaconda.storage.zfcp',
            'iutil',
            'constants',
            'flags',
            'anaconda_log',
            'parted',
            'block',
            'baseudev'])

        import pyanaconda.anaconda_log
        pyanaconda.anaconda_log.init()

        from pyanaconda import kickstart
        import pykickstart.version

        self.handler = pykickstart.version.makeVersion(kickstart.ver)

    def tearDown(self):
        self.tearDownModules()


    @acceptance
    def commands_test(self):
        for (commandName, commandObj) in kickstart.commandMap.iteritems():
            baseClass = commandObj().__class__.__bases__[0]
            pykickstartClass = self.handler.commands[commandName].__class__
            self.assertEqual(baseClass.__name__, pykickstartClass.__name__)

# Do the same thing as CommandVersionTestCase, but for data objects.
class DataVersionTestCase(TestCase):
    def setUp(self):
        import pyanaconda.anaconda_log
        pyanaconda.anaconda_log.init()

        from pyanaconda import kickstart
        import pykickstart.version

        self.handler = pykickstart.version.makeVersion(kickstart.ver)

    @acceptance
    def data_test(self):
        for (dataName, dataObj) in kickstart.dataMap.iteritems():
            baseClass = dataObj().__class__.__bases__[0]

            # pykickstart does not expose data objects a mapping the way it
            # does command objects.
            pykickstartClass = eval("self.handler.%s" % dataName)

            self.assertEqual(baseClass.__name__, pykickstartClass.__name__)