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')
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
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())
def test_run_bad_command(self): self.assertEqual(False, run(self.bad_command))
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))
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')
def test_run_good_command(self): self.assertEqual(b"test command\n", run(self.good_command))
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')
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')
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')
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')
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
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')
def test_run_bad_command_output(self): test_string = run(self.bad_command) self.assertEqual(False, run(self.bad_command))
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
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))
def test_run_missing_option(self): self.assertEqual(False, run(self.missing_option))
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()