Пример #1
0
 def test_get_status404_with_protocol(self):
     """Test that a status 404 is appropriately returned with GET"""
     response = run("status " + self.get_status404)
     self.assertEqual(response.strip().decode('ascii'), '404 : http://httpbin.org/status/404')
Пример #2
0
 def get_git_log(self):
     log_output = run('git log --numstat --reverse', suppress_stdout=True, suppress_stderr=False)
     if not log_output:
         print('Error fetching git log', file=sys.stderr)
         exit_fail()
     return log_output
Пример #3
0
 def test_get_status301_with_protocol(self):
     """Test that a status 301 and bounces are appropriately returned with GET"""
     response = run("status " + self.get_status301)
     self.assertEqual(response.strip().decode('ascii'), self.string_301.strip())
Пример #4
0
 def test_run_bad_command(self):
     self.assertEqual(False, run(self.bad_command))
Пример #5
0
 def test_run_bad_command_output(self):
     with self.assertRaises(
             SystemExit
     ):  # raises SystemExit when suppress_exit_status_call = False
         self.assertEqual(
             False, run(self.bad_command, suppress_exit_status_call=False))
Пример #6
0
 def test_post_p_status200_without_protocol(self):
     """Test that a status 200 is appropriately returned with POST using -p and no protocol"""
     response = run("status -p " + self.post_noprotocol)
     self.assertEqual(response.strip().decode('ascii'), '200 : http://httpbin.org/post')
Пример #7
0
 def test_run_good_command(self):
     self.assertEqual(b"test command\n", run(self.good_command))
Пример #8
0
 def test_post_post_status200_without_protocol(self):
     """Test that a status 200 is appropriately returned with POST using --post and no protocol"""
     response = run("status --post " + self.post_noprotocol)
     self.assertEqual(response.strip().decode('ascii'),
                      '200 : http://httpbin.org/post')
Пример #9
0
 def test_run_good_command(self):
     self.assertEqual(b"test command\n", run(self.good_command))
Пример #10
0
 def test_get_status200_without_protocol(self):
     """Test that a status 200 is returned appropriately when no protocol included"""
     response = run("status " + self.get_noprotocol)
     self.assertEqual(response.strip().decode('ascii'),
                      '200 : http://httpbin.org/status/200')
Пример #11
0
 def test_get_status200_ssl_protocol(self):
     """Test that a status 200 is returned appropriately with SSL protocol"""
     response = run("status " + self.get_ssl_protocol)
     self.assertEqual(response.strip().decode('ascii'),
                      '200 : https://httpbin.org/status/200')
Пример #12
0
 def test_get_status404_with_protocol(self):
     """Test that a status 404 is appropriately returned with GET"""
     response = run("status " + self.get_status404)
     self.assertEqual(response.strip().decode('ascii'),
                      '404 : http://httpbin.org/status/404')
Пример #13
0
 def test_get_status301_with_protocol(self):
     """Test that a status 301 and bounces are appropriately returned with GET"""
     response = run("status " + self.get_status301)
     self.assertEqual(response.strip().decode('ascii'),
                      self.string_301.strip())
Пример #14
0
 def test_post_p_status200_ssl(self):
     """Test that a status 200 is appropriately returned with POST using -p and https://"""
     response = run("status -p " + self.post_ssl_protocol)
     self.assertEqual(response.strip().decode('ascii'),
                      '200 : https://httpbin.org/post')
Пример #15
0
 def test_get_status200_without_protocol(self):
     """Test that a status 200 is returned appropriately when no protocol included"""
     response = run("status " + self.get_noprotocol)
     self.assertEqual(response.strip().decode('ascii'), '200 : http://httpbin.org/status/200')
Пример #16
0
 def test_run_good_command_suppress_stdout(self):
     self.assertEqual(b"test command\n", run(self.good_command, suppress_stdout=True)) # still receive return value when stout print suppressed
Пример #17
0
 def test_get_status200_ssl_protocol(self):
     """Test that a status 200 is returned appropriately with SSL protocol"""
     response = run("status " + self.get_ssl_protocol)
     self.assertEqual(response.strip().decode('ascii'), '200 : https://httpbin.org/status/200')
Пример #18
0
 def test_run_bad_command(self):
     self.assertEqual(False, run(self.bad_command))
Пример #19
0
 def test_post_post_status200_ssl(self):
     """Test that a status 200 is appropriately returned with POST using --post and https://"""
     response = run("status --post " + self.post_ssl_protocol)
     self.assertEqual(response.strip().decode('ascii'), '200 : https://httpbin.org/post')
Пример #20
0
 def test_run_bad_command_output(self):
     test_string = run(self.bad_command)
     self.assertEqual(False, run(self.bad_command))
Пример #21
0
 def test_run_good_command_suppress_stdout(self):
     self.assertEqual(
         b"test command\n", run(self.good_command, suppress_stdout=True)
     )  # still receive return value when stout print suppressed
Пример #22
0
 def test_run_bad_command_output(self):
     with self.assertRaises(SystemExit): # raises SystemExit when suppress_exit_status_call = False
         self.assertEqual(False, run(self.bad_command, suppress_exit_status_call=False))
Пример #23
0
 def test_run_bad_command_output(self):
     test_string = run(self.bad_command)
     self.assertEqual(False, run(self.bad_command))
Пример #24
0
 def test_run_missing_option(self):
     self.assertEqual(False, run(self.missing_option))
Пример #25
0
 def test_run_missing_option(self):
     self.assertEqual(False, run(self.missing_option))
Пример #26
0
 def ensure_git_repo(self):
     status_output = run('git status', suppress_stdout=True, suppress_stderr=True)
     if not status_output:
         print('Please run this command in a git repository', file=sys.stderr)
         exit_fail()