Fwd: [PATCH] Corrected return value of FC6_Iscsi parse method; Added iscsi, ignoredisk, langsupport test cases.

[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 2:17:06 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [PATCH] Corrected return value of FC6_Iscsi parse method; Added iscsi, ignoredisk, langsupport test cases.

---
 pykickstart/commands/iscsi.py |    4 +-
 tests/commands/ignoredisk.py  |   58 ++++++++++++++++++++++++++++++++++
 tests/commands/iscsi.py       |   70 +++++++++++++++++++++++++++++++++++++++++
 tests/commands/langsupport.py |   47 +++++++++++++++++++++++++++
 4 files changed, 177 insertions(+), 2 deletions(-)
 create mode 100644 tests/commands/ignoredisk.py
 create mode 100644 tests/commands/iscsi.py
 create mode 100644 tests/commands/langsupport.py

diff --git a/pykickstart/commands/iscsi.py b/pykickstart/commands/iscsi.py
index 3a451e6..582dfc3 100644
--- a/pykickstart/commands/iscsi.py
+++ b/pykickstart/commands/iscsi.py
@@ -16,7 +16,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 *
@@ -114,7 +114,7 @@ class FC6_Iscsi(KickstartCommand):
 
         dd = self.handler.IscsiData()
         self._setToObj(self.op, opts, dd)
-        return self
+        return dd
 
     def dataList(self):
         return self.iscsi
diff --git a/tests/commands/ignoredisk.py b/tests/commands/ignoredisk.py
new file mode 100644
index 0000000..99bf69f
--- /dev/null
+++ b/tests/commands/ignoredisk.py
@@ -0,0 +1,58 @@
+#
+# 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
+        self.assert_parse("ignoredisk --drives=sda", "ignoredisk --drives=sda\n")
+        self.assert_parse("ignoredisk --drives=sda,sdb", "ignoredisk --drives=sda,sdb\n")
+        # empty
+        self.assert_parse("ignoredisk", "")
+
+        # fail
+        # wrong option name
+        self.assert_parse_error("ignoredisk --devices=sda", KickstartParseError)
+        # missing arguments
+        self.assert_parse_error("ignoredisk --drives", KickstartParseError)
+
+
+class F8_TestCase(FC3_TestCase):
+    def runTest(self):
+        # run FC3 test case
+        FC3_TestCase.runTest(self)
+
+        # pass
+        self.assert_parse("ignoredisk --only-use=sda", "ignoredisk --only-use=sda\n")
+        self.assert_parse("ignoredisk --only-use=sda,sdb", "ignoredisk --only-use=sda,sdb\n")
+
+        # ignore --only-use option if also --drives provided
+        self.assert_parse("ignoredisk --drives=sda --only-use=sdb", "ignoredisk --drives=sda\n")
+        self.assert_parse("ignoredisk --only-use=sda --drives=sdb", "ignoredisk --drives=sdb\n")
+
+        # fail
+        # missing arguments
+        self.assert_parse_error("ignoredisk --only-use", KickstartParseError)
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/tests/commands/iscsi.py b/tests/commands/iscsi.py
new file mode 100644
index 0000000..6bf312a
--- /dev/null
+++ b/tests/commands/iscsi.py
@@ -0,0 +1,70 @@
+#
+# 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 FC6_TestCase(CommandTest):
+    def runTest(self):
+        # pass
+        self.assert_parse("iscsi --ipaddr=1.1.1.1", "iscsi --ipaddr=1.1.1.1\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --target=tar --port=1234 --user=name --password=secret",
+                          "iscsi --target=tar --ipaddr=1.1.1.1 --port=1234 --user=name --password=secret\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --target=tar", "iscsi --target=tar --ipaddr=1.1.1.1\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --port=1234", "iscsi --ipaddr=1.1.1.1 --port=1234\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --user=name", "iscsi --ipaddr=1.1.1.1 --user=name\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --password=secret", "iscsi --ipaddr=1.1.1.1 --password=secret\n")
+
+        # fail
+        # missing required option --ipaddr
+        self.assert_parse_error("iscsi", KickstartValueError)
+        self.assert_parse_error("iscsi --target=tar --user=name --password=secret --port=1234", KickstartValueError)
+        # missing --ipaddr argument
+        self.assert_parse_error("iscsi --ipaddr", KickstartParseError)
+        # unexpected arguments
+        self.assert_parse_error("iscsi --ipaddr=1.2.3.4 not expected", KickstartValueError)
+        # unknown flag
+        self.assert_parse_error("iscsi --ipaddr=1.2.3.4 --unknown=value", KickstartParseError)
+        # empty arguments
+        self.assert_parse_error("iscsi --target --ipaddr=1.2.3.4", KickstartParseError)
+        self.assert_parse_error("iscsi --ipaddr=1.2.3.4 --user", KickstartParseError)
+        self.assert_parse_error("iscsi --ipaddr=1.2.3.4 --password", KickstartParseError)
+        self.assert_parse_error("iscsi --ipaddr=1.2.3.4 --port", KickstartParseError)
+
+
+class F10_TestCase(FC6_TestCase):
+    def runTest(self):
+        # run FC6 test case
+        FC6_TestCase.runTest(self)
+
+        # pass
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --reverse-user=name --reverse-password=secret",
+                          "iscsi --ipaddr=1.1.1.1 --reverse-user=name --reverse-password=secret\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --reverse-user=name", "iscsi --ipaddr=1.1.1.1 --reverse-user=name\n")
+        self.assert_parse("iscsi --ipaddr=1.1.1.1 --reverse-password=secret", "iscsi --ipaddr=1.1.1.1 --reverse-password=secret\n")
+
+        # fail
+        # empty arguments
+        self.assert_parse_error("iscsi --ipaddr=1.1.1.1 --reverse-user", KickstartParseError)
+        self.assert_parse_error("iscsi --ipaddr=1.1.1.1 --reverse-password", KickstartParseError)
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/tests/commands/langsupport.py b/tests/commands/langsupport.py
new file mode 100644
index 0000000..eaebea3
--- /dev/null
+++ b/tests/commands/langsupport.py
@@ -0,0 +1,47 @@
+#
+# 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
+        self.assert_parse("langsupport --default=sk_SK.UTF-8", "langsupport --default=sk_SK.UTF-8\n")
+        self.assert_parse("langsupport", "langsupport --default=en_US.UTF-8\n")
+        self.assert_parse("langsupport --default=sk_SK.UTF-8 en_US cs_CZ", "langsupport --default=sk_SK.UTF-8 en_US cs_CZ\n")
+        self.assert_parse("langsupport en_US cs_CZ", "langsupport --default=en_US.UTF-8 en_US cs_CZ\n")
+
+        # fail
+        # wrong option name
+        self.assert_parse_error("langsupport --locale=en_US", KickstartParseError)
+        # missing --default argument
+        self.assert_parse_error("langsupport --default", KickstartParseError)
+
+
+class FC5_TestCase(FC3_TestCase):
+    def runTest(self):
+        # pass
+        # deprecated command
+        pass
+
+
+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