@patch('<STR_LIT>')<EOL>@patch('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>def _request_and_assert(request_call,<EOL>expected_call,<EOL>status_code,<EOL>reason,<EOL>mock_request,<EOL>mock_sleep):
def _response_generator(bad_status_code, reason):<EOL><INDENT>bad_response = Response({})<EOL>bad_response.status = bad_status_code<EOL>bad_response.reason = reason<EOL>good_response = Response({})<EOL>good_response.status = <NUM_LIT:200><EOL>content = '<STR_LIT>'<EOL>return [(bad_response, content),<EOL>(bad_response, content),<EOL>(good_response, content)]<EOL><DEDENT>mock_request.side_effect = _response_generator(status_code, reason)<EOL>request_call()<EOL>assert_equal(<EOL>[call(<NUM_LIT:10>), call(<NUM_LIT:20>)],<EOL>mock_sleep.call_args_list)<EOL>assert_equal(<EOL>[expected_call,<EOL>expected_call,<EOL>expected_call],<EOL>mock_request.call_args_list)<EOL>
Send a passed in request to HttpWithBackoff and check
that the wrapped requests package makes an equivalent request
with identical parameters. Also check that sleep was called
in the way expected when the first two requests are bad and
have the passed in status_code.