From 872e5970db67e07e53903a048fffae84f9eda1e5 Mon Sep 17 00:00:00 2001 From: Martin Gracik Date: Mon, 9 Feb 2009 11:41:29 -0500 Subject: [PATCH] Added mouse test case. --- pykickstart/commands/mouse.py | 12 ++++++++++-- tests/commands/mouse.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/commands/mouse.py diff --git a/pykickstart/commands/mouse.py b/pykickstart/commands/mouse.py index 27e248f..a835152 100644 --- a/pykickstart/commands/mouse.py +++ b/pykickstart/commands/mouse.py @@ -15,11 +15,15 @@ # 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. +# with the express permission of Red Hat, Inc. # from pykickstart.base import * +from pykickstart.errors import * from pykickstart.options import * +import gettext +_ = lambda x: gettext.ldgettext("pykickstart", x) + class RHEL3_Mouse(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -39,7 +43,7 @@ class RHEL3_Mouse(KickstartCommand): if self.device: opts += "--device=%s " % self.device if self.emulthree: - opts += "--emulthree " + opts += "--emulthree " if self.mouse: retval += "# System mouse\nmouse %s%s\n" % (opts, self.mouse) @@ -54,6 +58,10 @@ class RHEL3_Mouse(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args) self._setToSelf(self.op, opts) + + if len(extra) != 1: + raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse") + self.mouse = extra[0] return self diff --git a/tests/commands/mouse.py b/tests/commands/mouse.py new file mode 100644 index 0000000..7f87d12 --- /dev/null +++ b/tests/commands/mouse.py @@ -0,0 +1,41 @@ +# +# 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 RHEL3_TestCase(CommandTest): + def runTest(self): + # pass + self.assert_parse("mouse jerry", "mouse jerry\n") + self.assert_parse("mouse --device=/dev/mice --emulthree jerry", "mouse --device=/dev/mice --emulthree jerry\n") + self.assert_parse("mouse jerry --device=/dev/mice", "mouse --device=/dev/mice jerry\n") + self.assert_parse("mouse jerry --emulthree", "mouse --emulthree jerry\n") + + # fail + # empty + self.assert_parse_error("mouse", KickstartValueError) + # unknown option + self.assert_parse_error("mouse jerry --bad-flag", KickstartParseError) + # --device requires argument + self.assert_parse_error("mouse jerry --device", KickstartParseError) + +if __name__ == "__main__": + unittest.main() -- 2.11.4.GIT