Fwd: [PATCH] Added method test case; Corrected newline char in return value of FC6_Method.

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

 



----- Forwarded Message -----
From: "Martin Gracik" <mgracik@xxxxxxxxxx>
To: kickstart-list@xxxxxxxxxx
Cc: "Martin Gracik" <mgracik@xxxxxxxxxx>
Sent: Monday, February 9, 2009 3:12:22 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [PATCH] Added method test case; Corrected newline char in return value of FC6_Method.

When using nfs command without the --opts, the FC6_Method.__str__() didn't append the "\n" character to the end of the string.
---
 pykickstart/commands/method.py |    5 +-
 tests/commands/method.py       |   88 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 2 deletions(-)
 create mode 100644 tests/commands/method.py

diff --git a/pykickstart/commands/method.py b/pykickstart/commands/method.py
index 025dd4b..9d6558c 100644
--- a/pykickstart/commands/method.py
+++ b/pykickstart/commands/method.py
@@ -15,7 +15,7 @@
 # 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 *
@@ -115,7 +115,8 @@ class FC6_Method(FC3_Method):
         elif self.method == "nfs":
             retval += "# Use NFS installation media\nnfs --server=%s --dir=%s" % (self.server, self.dir)
             if self.opts is not None:
-                retval += " --opts=\"%s\"\n" % self.opts
+                retval += " --opts=\"%s\"" % self.opts
+            retval += "\n"
         elif self.method == "url":
             retval += "# Use network installation\nurl --url=%s\n" % self.url
 
diff --git a/tests/commands/method.py b/tests/commands/method.py
new file mode 100644
index 0000000..1c17630
--- /dev/null
+++ b/tests/commands/method.py
@@ -0,0 +1,88 @@
+#
+# Martin Gracik <mgracik@xxxxxxxxxx>
+#
+# 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
+        # cdrom
+        self.assert_parse("cdrom", "cdrom\n")
+
+        # harddrive
+        self.assert_parse("harddrive --dir=/install --biospart=part", "harddrive --dir=/install --biospart=part\n")
+        self.assert_parse("harddrive --dir=/install --partition=part", "harddrive --dir=/install --partition=part\n")
+
+        # nfs
+        self.assert_parse("nfs --server=1.2.3.4 --dir=/install", "nfs --server=1.2.3.4 --dir=/install\n")
+
+        # url
+        self.assert_parse("url --url=http://domain.com";, "url --url=http://domain.com\n";)
+
+        # fail
+        # harddrive
+        # required option --dir missing
+        self.assert_parse_error("harddrive", KickstartValueError)
+        # required --dir argument missing
+        self.assert_parse_error("harddrive --dir", KickstartParseError)
+        # missing --biospart or --partition option
+        self.assert_parse_error("harddrive --dir=/install", KickstartValueError)
+        # both --biospart and --partition specified
+        self.assert_parse_error("harddrive --dir=/install --biospart=bios --partition=part", KickstartValueError)
+        # --biospart and --partition require argument
+        self.assert_parse_error("harddrive --dir=/install --biospart", KickstartParseError)
+        self.assert_parse_error("harddrive --dir=/install --partition", KickstartParseError)
+        # unknown option
+        self.assert_parse_error("harddrive --unknown=value", KickstartParseError)
+
+        # nfs
+        # missing required options --server and --dir
+        self.assert_parse_error("nfs", KickstartValueError)
+        self.assert_parse_error("nfs --server=1.2.3.4", KickstartValueError)
+        self.assert_parse_error("nfs --server", KickstartParseError)
+        self.assert_parse_error("nfs --dir=/install", KickstartValueError)
+        self.assert_parse_error("nfs --dir", KickstartParseError)
+        # unknown option
+        self.assert_parse_error("nfs --unknown=value", KickstartParseError)
+
+        # url
+        # missing required option --url
+        self.assert_parse_error("url", KickstartValueError)
+        self.assert_parse_error("url --url", KickstartParseError)
+
+
+class FC6_TestCase(FC3_TestCase):
+    def runTest(self):
+        # run FC3 test case
+        FC3_TestCase.runTest(self)
+
+        # pass
+        # nfs
+        self.assert_parse("nfs --server=1.2.3.4 --dir=/install --opts=options", "nfs --server=1.2.3.4 --dir=/install --opts=\"options\"\n")
+
+        # fail
+        # nfs
+        # --opts requires argument if specified
+        self.assert_parse_error("nfs --server=1.2.3.4 --dir=/install --opts", KickstartParseError)
+
+
+if __name__ == "__main__":
+    unittest.main()
-- 
1.6.0.6

_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list

[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux