From 6db004e9d400bbef6ff6298839c9f754fdf481e9 Mon Sep 17 00:00:00 2001 From: Martin Gracik Date: Mon, 9 Feb 2009 11:41:36 -0500 Subject: [PATCH] Added reboot, upgrade, user, zerombr test cases. --- tests/commands/upgrade.py | 52 +++++++++++++++++++++++++++++++++++++ tests/commands/user.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++ tests/commands/zerombr.py | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) 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/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 +# +# 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 +# +# 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 +# +# 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() -- 2.11.4.GIT