From 1ac160e8c23c658539efa1b6860706eab3e0186a Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Sun, 15 Mar 2020 11:04:50 +0100 Subject: [PATCH] Add boilerplate for CLI tests --- test/test_main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_main.py b/test/test_main.py index ca74043..873c62d 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -4,6 +4,7 @@ import unittest import unittest.mock as mock import sys +import os sys.path.append('..') @@ -15,6 +16,16 @@ class MainTest(unittest.TestCase): Tests for main """ + def setUp(self): + """ + Defining the exitcodes + """ + + self.exit_0 = 0 << 8 + self.exit_1 = 1 << 8 + self.exit_2 = 2 << 8 + self.exit_3 = 3 << 8 + def test_debugprint(self): with mock.patch('builtins.print') as mock_print: debugPrint(True, 'debug') @@ -24,3 +35,10 @@ class MainTest(unittest.TestCase): with mock.patch('check_http_json.pprint') as mock_pprint: debugPrint(True, 'debug', True) mock_pprint.assert_called_once_with('debug') + + def test_cli_without_params(self): + + command = '/usr/bin/env python3 check_http_json.py > /dev/null 2>&1' + status = os.system(command) + + self.assertEqual(status, self.exit_2)