Fwd: [PATCH] Added reboot, upgrade, user, zerombr test cases.
Martin Gracik
mgracik at redhat.com
Mon Feb 9 16:41:36 UTC 2009
----- Forwarded Message -----
From: "Martin Gracik" <mgracik at redhat.com>
To: kickstart-list at redhat.com
Cc: "Martin Gracik" <mgracik at redhat.com>
Sent: Monday, February 9, 2009 5:24:51 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [PATCH] Added reboot, upgrade, user, zerombr test cases.
---
tests/commands/reboot.py | 43 +++++++++++++++++++++++++++++
tests/commands/upgrade.py | 52 +++++++++++++++++++++++++++++++++++
tests/commands/user.py | 66 +++++++++++++++++++++++++++++++++++++++++++++
tests/commands/zerombr.py | 46 +++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+), 0 deletions(-)
create mode 100644 tests/commands/reboot.py
create mode 100644 tests/commands/upgrade.py
create mode 100644 tests/commands/user.py
create mode 100644 tests/commands/zerombr.py
diff --git a/tests/commands/reboot.py b/tests/commands/reboot.py
new file mode 100644
index 0000000..258a7bf
--- /dev/null
+++ b/tests/commands/reboot.py
@@ -0,0 +1,43 @@
+#
+# Martin Gracik <mgracik at redhat.com>
+#
+# Copyright 2009 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use, modify,
+# copy, or redistribute it subject to the terms and conditions of the GNU
+# General Public License v.2. This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc.
+#
+
+import unittest
+from tests.baseclass import *
+
+class FC3_TestCase(CommandTest):
+ def runTest(self):
+ # pass
+ self.assert_parse("reboot", "reboot\n")
+ self.assert_parse("shutdown", "shutdown\n")
+
+ # fail
+
+
+class FC6_TestCase(FC3_TestCase):
+ def runTest(self):
+ # pass
+ self.assert_parse("reboot --eject", "reboot --eject\n")
+ self.assert_parse("shutdown --eject", "shutdown --eject\n")
+
+ # fail
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/commands/upgrade.py b/tests/commands/upgrade.py
new file mode 100644
index 0000000..dd7e878
--- /dev/null
+++ b/tests/commands/upgrade.py
@@ -0,0 +1,52 @@
+#
+# Martin Gracik <mgracik at redhat.com>
+#
+# Copyright 2009 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use, modify,
+# copy, or redistribute it subject to the terms and conditions of the GNU
+# General Public License v.2. This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc.
+#
+
+import unittest
+from tests.baseclass import *
+
+class FC3_TestCase(CommandTest):
+ def runTest(self):
+ # pass
+ self.assert_parse("upgrade", "upgrade\n")
+ self.assert_parse("install", "install\n")
+
+ # fail
+ self.assert_parse_error("upgrade install", KickstartValueError)
+ self.assert_parse_error("upgrade --bad-flag", KickstartValueError)
+ self.assert_parse_error("install --bad-flag", KickstartValueError)
+
+
+class F11_TestCase(FC3_TestCase):
+ def runTest(self):
+ # pass
+ self.assert_parse("upgrade", "upgrade\n")
+ self.assert_parse("install", "install\n")
+ self.assert_parse("upgrade --root-device=/dev/sda", "upgrade --root-device=/dev/sda\n")
+ self.assert_parse("install --root-device=/dev/sda", "install\n")
+
+ # fail
+ # --root-device requires argument
+ self.assert_parse_error("upgrade --root-device", KickstartParseError)
+ # unknown option
+ self.assert_parse_error("upgrade --bad-flag", KickstartParseError)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/commands/user.py b/tests/commands/user.py
new file mode 100644
index 0000000..9f1a74d
--- /dev/null
+++ b/tests/commands/user.py
@@ -0,0 +1,66 @@
+#
+# Martin Gracik <mgracik at redhat.com>
+#
+# Copyright 2009 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use, modify,
+# copy, or redistribute it subject to the terms and conditions of the GNU
+# General Public License v.2. This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc.
+#
+
+import unittest
+from tests.baseclass import *
+
+class FC6_TestCase(CommandTest):
+ def runTest(self):
+ # pass
+ self.assert_parse("user --name=user", "user --name=user\n")
+ self.assert_parse("user --name=user --groups=grp1,grp2 --homedir=/home/user --shell=/bin/bash --uid=1000 --password=secret --iscrypted",
+ "user --groups=grp1,grp2 --homedir=/home/user --name=user --password=secret --iscrypted --shell=/bin/bash --uid=1000\n")
+ self.assert_parse("user --name=user --groups=grp1", "user --groups=grp1 --name=user\n")
+ self.assert_parse("user --name=user --homedir=/home/user --shell=/bin/bash", "user --homedir=/home/user --name=user --shell=/bin/bash\n")
+ self.assert_parse("user --name=user --password=secret", "user --name=user --password=secret\n")
+ self.assert_parse("user --name=user --uid=1000", "user --name=user --uid=1000\n")
+
+ # fail
+ # missing required option --name
+ self.assert_parse_error("user", KickstartValueError)
+ # --name requires an argument
+ self.assert_parse_error("user --name", KickstartParseError)
+ # --uid requires int argument
+ self.assert_parse_error("user --name=user --uid=id", KickstartParseError)
+ # unknown option
+ self.assert_parse_error("user --name=user --unknown=value", KickstartParseError)
+ # required option arguments
+ self.assert_parse_error("user --name=user --groups", KickstartParseError)
+ self.assert_parse_error("user --name=user --homedir", KickstartParseError)
+ self.assert_parse_error("user --name=user --shell", KickstartParseError)
+ self.assert_parse_error("user --name=user --uid", KickstartParseError)
+ self.assert_parse_error("user --name=user --password", KickstartParseError)
+
+
+class F8_TestCase(FC6_TestCase):
+ def runTest(self):
+ # run FC6 test case
+ FC6_TestCase.runTest(self)
+
+ # pass
+ self.assert_parse("user --name=user --lock --plaintext", "user --name=user --lock\n")
+ self.assert_parse("user --name=user --lock", "user --name=user --lock\n")
+ self.assert_parse("user --name=user --plaintext", "user --name=user\n")
+
+ # fail
+
+
+if __name__ == "__main__":
+ unittest.main()
\ No newline at end of file
diff --git a/tests/commands/zerombr.py b/tests/commands/zerombr.py
new file mode 100644
index 0000000..8a31436
--- /dev/null
+++ b/tests/commands/zerombr.py
@@ -0,0 +1,46 @@
+#
+# Martin Gracik <mgracik at redhat.com>
+#
+# Copyright 2009 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use, modify,
+# copy, or redistribute it subject to the terms and conditions of the GNU
+# General Public License v.2. This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc.
+#
+
+import unittest
+from tests.baseclass import *
+
+class FC3_TestCase(CommandTest):
+ def runTest(self):
+ # pass
+ self.assert_parse("zerombr", "zerombr\n")
+ # ignoring arguments
+ self.assert_parse("zerombr arg", "zerombr\n")
+
+ # fail
+
+
+class F9_TestCase(FC3_TestCase):
+ def runTest(self):
+ # pass
+ self.assert_parse("zerombr", "zerombr\n")
+
+ # fail
+ # zerombr does not take any arguments
+ self.assert_parse_error("zerombr arg", KickstartParseError)
+ self.assert_parse_error("zerombr --bad-flag", KickstartParseError)
+
+
+if __name__ == "__main__":
+ unittest.main()
--
1.6.0.6
More information about the Kickstart-list
mailing list