def test_client_shutdown(jedihttp): response = requests.post('http://127.0.0.1:{0}/shutdown'.format(PORT), auth=HmacAuth(SECRET)) assert_that(response.status_code, equal_to(httplib.OK)) assert_that(response.json(), equal_to(True)) hmachelper = hmaclib.JediHTTPHmacHelper(SECRET) assert_that(hmachelper.is_response_authenticated(response.headers, response.content)) wait_process_shutdown(jedihttp) assert_that(process_is_running(jedihttp), equal_to(False))
def teardown_jedihttp(jedihttp): try: requests.post('http://127.0.0.1:{0}/shutdown'.format(PORT), auth=HmacAuth(SECRET)) except requests.exceptions.ConnectionError: pass try: wait_process_shutdown(jedihttp) except RuntimeError: jedihttp.terminate() stdout, _ = jedihttp.communicate() sys.stdout.write(decode_string(stdout))
def test_client_shutdown_from_watchdog(jedihttp): wait_process_shutdown(jedihttp, timeout=10) assert_that(process_is_running(jedihttp), equal_to(False))