summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2010-04-13 13:38:09 -0400
committerChris Lumens <clumens@redhat.com>2010-04-13 15:10:44 -0400
commit5fbd314619addb0009f9e5f079a822e0cf768bc2 (patch)
tree4532544ac735c5c71c6f876b1c82116d48b1421d
parentaeaaa44a33bf01ab4b5e1806ef2884b65c6ebc2a (diff)
downloadanaconda-5fbd314619addb0009f9e5f079a822e0cf768bc2.tar.gz
anaconda-5fbd314619addb0009f9e5f079a822e0cf768bc2.tar.xz
anaconda-5fbd314619addb0009f9e5f079a822e0cf768bc2.zip
Add a test case to verify that kickstart commands use the right handler.
The aim of this is to prevent bugs like 581829, where a later version of a command is added in pykickstart but anaconda is never updated to use the right version. Of course, this shifts the burden from updating kickstart.py to running the test case. But it's better than nothing.
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/kickstart/Makefile.am22
-rw-r--r--tests/kickstart/__init__.py0
-rw-r--r--tests/kickstart/commands.py52
5 files changed, 76 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index aa5642340..eb92ff887 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,6 +272,7 @@ AC_CONFIG_FILES([Makefile
storage/devicelibs/Makefile
storage/formats/Makefile
tests/Makefile
+ tests/kickstart/Makefile
tests/storage/Makefile
tests/storage/devicelibs/Makefile
textw/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 062b93170..1c7d661c5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,7 @@
#
# Author: David Cantrell <dcantrell@redhat.com>
-SUBDIRS = storage
+SUBDIRS = kickstart storage
EXTRA_DIST = *.py
diff --git a/tests/kickstart/Makefile.am b/tests/kickstart/Makefile.am
new file mode 100644
index 000000000..20b7a149d
--- /dev/null
+++ b/tests/kickstart/Makefile.am
@@ -0,0 +1,22 @@
+# tests/kickstart/Makefile.am for anaconda
+#
+# 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>
+
+EXTRA_DIST = *.py
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/tests/kickstart/__init__.py b/tests/kickstart/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/kickstart/__init__.py
diff --git a/tests/kickstart/commands.py b/tests/kickstart/commands.py
new file mode 100644
index 000000000..0be37b4fe
--- /dev/null
+++ b/tests/kickstart/commands.py
@@ -0,0 +1,52 @@
+#
+# 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 kickstart
+import pykickstart.version
+
+# 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(unittest.TestCase):
+ def setUp(self):
+ self.handler = pykickstart.version.makeVersion(kickstart.ver)
+
+ def runTest(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(unittest.TestCase):
+ def setUp(self):
+ self.handler = pykickstart.version.makeVersion(kickstart.ver)
+
+ def runTest(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__)
+
+if __name__ == "__main__":
+ unittest.main()