def test_check_args_mendatory(self): """Test check_args_mendatory : -<empty> """ sys.argv = [sys.argv[0]] try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("""UNKNOWN - Argument '""")
def test_help(self): """Test help output : -h """ sys.argv = [sys.argv[0]] sys.argv.append('-h') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("""check_samba""")
def test_bad_options(self): """Test check_args : -X """ sys.argv = [sys.argv[0]] sys.argv.append('-X') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("""option """)
def test_version(self): """Test version output : -V """ sys.argv = [sys.argv[0]] sys.argv.append('-V') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("check_samba.py v%s" % check_samba.PLUGIN_VERSION)
def test_bad_hostname(self): """Test bad_hostname : -H foo-bar -s test_shinken """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('foo-bar') sys.argv.append('-s') sys.argv.append('test_shinken') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 2) output = out.getvalue().strip() assert output.startswith("""CRITICAL - Can't connect to """)
def test_bad_ip(self): """Test bad_ip : -H 992.168.50.254 -s test_shinken """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('192.168.50.254') sys.argv.append('-s') sys.argv.append('test_shinken') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 2) output = out.getvalue().strip() assert output.startswith("""CRITICAL - UNKNOWN Ip address :""")
def test_check_args_couple(self): """Test check_args_couple : -H """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('192.168.50.23') sys.argv.append('-s') sys.argv.append('test_shinken') sys.argv.append('-w') sys.argv.append('10') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("""UNKNOWN - You can't specify only warning or critical.""")
def test_check_args_couple(self): """Test check_args_couple : -H """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('192.168.50.23') sys.argv.append('-s') sys.argv.append('test_shinken') sys.argv.append('-w') sys.argv.append('10') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith( """UNKNOWN - You can't specify only warning or critical.""")
def test_bad_values(self): """Test bad_values : -H 192.168.50.23 -s test_shinken """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('192.168.50.23') sys.argv.append('-s') sys.argv.append('test_shinken') sys.argv.append('-w') sys.argv.append('10') sys.argv.append('-c') sys.argv.append('9') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith("""UNKNOWN - Wrong warning, critical or timeout values""")
def test_bad_values(self): """Test bad_values : -H 192.168.50.23 -s test_shinken """ sys.argv = [sys.argv[0]] sys.argv.append('-H') sys.argv.append('192.168.50.23') sys.argv.append('-s') sys.argv.append('test_shinken') sys.argv.append('-w') sys.argv.append('10') sys.argv.append('-c') sys.argv.append('9') try: out = StringIO() sys.stdout = out check_samba.main() except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 3) output = out.getvalue().strip() assert output.startswith( """UNKNOWN - Wrong warning, critical or timeout values""")