[PATCH] Add a test case to verify that kickstart commands use the right handler.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 configure.ac                |    1 +
 tests/Makefile.am           |    2 +-
 tests/kickstart/Makefile.am |   22 +++++++++++++++++
 tests/kickstart/commands.py |   53 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 1 deletions(-)
 create mode 100644 tests/kickstart/Makefile.am
 create mode 100644 tests/kickstart/__init__.py
 create mode 100644 tests/kickstart/commands.py

diff --git a/configure.ac b/configure.ac
index aa56423..eb92ff8 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 062b931..1c7d661 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,7 @@
 #
 # Author: David Cantrell <dcantrell@xxxxxxxxxx>
 
-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 0000000..20b7a14
--- /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@xxxxxxxxxx>
+
+EXTRA_DIST = *.py
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/tests/kickstart/__init__.py b/tests/kickstart/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/kickstart/commands.py b/tests/kickstart/commands.py
new file mode 100644
index 0000000..ce51c39
--- /dev/null
+++ b/tests/kickstart/commands.py
@@ -0,0 +1,53 @@
+# 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@xxxxxxxxxx>
+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()
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux