aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests/exception_tests.py
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-04-29 12:57:00 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-05-03 10:48:26 -0400
commitea15997dc140a9b5506c012617cc23db0a6ae6fc (patch)
treeefbfdffcdc05948e4cdccd3fb807f53101d06961 /tests/report_tests/exception_tests.py
parent808d9f35ac504a58c337ffed14b39119a591808f (diff)
downloadsos-ea15997dc140a9b5506c012617cc23db0a6ae6fc.tar.gz
[tests] Add test class for when exceptions are expected in an execution
Adds a new `StageOneReportExceptionTest` class that is to be used for tests that should ensure an exception IS hit, for example when testing plugin enablement or invalid options. Included with this commit is a small set of plugin enablement tests. Future tests for component and plugin specific exception handling should be built using this class and design approach. Resolves: #2518 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests/exception_tests.py')
-rw-r--r--tests/report_tests/exception_tests.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/report_tests/exception_tests.py b/tests/report_tests/exception_tests.py
new file mode 100644
index 00000000..652b9ebb
--- /dev/null
+++ b/tests/report_tests/exception_tests.py
@@ -0,0 +1,43 @@
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos_tests import StageOneReportExceptionTest
+
+
+class InvalidPluginEnabledTest(StageOneReportExceptionTest):
+ """
+ :avocado: tags=stageone
+ """
+
+ sos_cmd = '-o foobar'
+
+ def test_caught_invalid_plugin(self):
+ self.assertOutputContains('a non-existing plugin \(foobar\)')
+
+
+class InvalidPluginOptionTest(StageOneReportExceptionTest):
+ """
+ :avocado: tags=stageone
+ """
+
+ sos_cmd = '-o kernel -k kernel.colonel=on'
+
+ def test_caught_invalid_plugin_option(self):
+ self.assertOutputContains('no such option "colonel" for plugin \(kernel\)')
+
+
+class InvalidReportOptionTest(StageOneReportExceptionTest):
+ """
+ :avocado: tags=stageone
+ """
+
+ sos_cmd = '--magic'
+
+ def test_caught_invalid_option(self):
+ self.assertOutputContains('unrecognized arguments\: --magic')
+