def test_help(self):
     """Test help output :
        -h
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-h')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("""check_site_health""")
 def test_help(self):
     """Test help output :
        -h
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-h')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("""check_site_health""")
 def test_bad_arguments4(self):
     """Test bad arguments4:
        -o 200,302
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-o')
     sys.argv.append('200,302')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("Argument `hostname' is missing !")
 def test_sflphone_org(self):
     """Test sflphone.org (must have broken pages):
        -H sflphone.org
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('sflphone.org')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("CRITICAL")
 def test_version(self):
     """Test version output :
        -V
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-V')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("check_site_health.py v%s" %
                                  check_site_health.PLUGIN_VERSION)
 def test_version(self):
     """Test version output :
        -V
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-V')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("check_site_health.py v%s"
                                  % check_site_health.PLUGIN_VERSION)
 def test_sflphone_org(self):
     """Test sflphone.org (must have broken pages):
        -H sflphone.org
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('sflphone.org')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("CRITICAL")
 def test_google_com2(self):
     """Test google.com2:
        -H google.com
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('google.com')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 0)
         output = out.getvalue().strip()
         assert output.startswith("OK")
 def test_bad_arguments4(self):
     """Test bad arguments4:
        -o 200,302
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-o')
     sys.argv.append('200,302')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("Argument `hostname' is missing !")
 def test_google_com2(self):
     """Test google.com2:
        -H google.com
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('google.com')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 0)
         output = out.getvalue().strip()
         assert output.startswith("OK")
 def test_bad_arguments2(self):
     """Test bad arguments2:
        -H 127.0.0.1 -f
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-f')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("option -f not recognized")
 def test_bad_arguments2(self):
     """Test bad arguments2:
        -H 127.0.0.1 -f
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-f')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("option -f not recognized")
 def test_bad_arguments1(self):
     """Test bad arguments1:
        -H 127.0.0.1 -w toto
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-w')
     sys.argv.append('toto')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("Bad format for WARNING argument")
 def test_bad_site(self):
     """Test bad_site.comd:
        -H bad_site.comd -o 200,302
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('bad_site.comd')
     sys.argv.append('-o')
     sys.argv.append('200,302')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("CRITICAL")
 def test_bad_arguments1(self):
     """Test bad arguments1:
        -H 127.0.0.1 -w toto
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-w')
     sys.argv.append('toto')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("Bad format for WARNING argument")
 def test_bad_site(self):
     """Test bad_site.comd:
        -H bad_site.comd -o 200,302
     """ 
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('bad_site.comd')
     sys.argv.append('-o')
     sys.argv.append('200,302')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("CRITICAL")
 def test_bad_arguments3(self):
     """Test bad arguments3:
        -H 127.0.0.1 -o 200 -w 404
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-o')
     sys.argv.append('200')
     sys.argv.append('-w')
     sys.argv.append('404')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("You can define OK option and WARNING/CRITICAL options")
 def test_bad_arguments3(self):
     """Test bad arguments3:
        -H 127.0.0.1 -o 200 -w 404
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('127.0.0.1')
     sys.argv.append('-o')
     sys.argv.append('200')
     sys.argv.append('-w')
     sys.argv.append('404')
     try:
         out = StringIO()
         sys.stdout = out
         check_site_health.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith(
             "You can define OK option and WARNING/CRITICAL options")