def setup_mock_redmine_server(max_failures=<NUM_LIT:0>):
http_requests = []<EOL>failures = max_failures<EOL>issues_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issues_next_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issues_empty_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issue_2_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issue_5_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issue_9_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>issue_7311_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>user_3_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>user_4_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>user_24_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>user_25_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>def request_callback(method, uri, headers):<EOL><INDENT>nonlocal failures<EOL>status = <NUM_LIT:200><EOL>last_request = httpretty.last_request()<EOL>params = last_request.querystring<EOL>if uri.startswith(REDMINE_ISSUES_URL):<EOL><INDENT>updated_on = params['<STR_LIT>'][<NUM_LIT:0>]<EOL>offset = params['<STR_LIT>'][<NUM_LIT:0>]<EOL>if (updated_on == '<STR_LIT>' and offset == '<STR_LIT:0>'):<EOL><INDENT>body = issues_body<EOL><DEDENT>elif (updated_on == '<STR_LIT>' and offset == '<STR_LIT:3>'):<EOL><INDENT>body = issues_next_body<EOL><DEDENT>elif (updated_on == '<STR_LIT>' and offset == '<STR_LIT:0>'):<EOL><INDENT>body = issues_next_body<EOL><DEDENT>elif (updated_on == '<STR_LIT>' and offset == '<STR_LIT:0>'):<EOL><INDENT>body = issues_next_body<EOL><DEDENT>else:<EOL><INDENT>body = issues_empty_body<EOL><DEDENT><DEDENT>elif uri.startswith(REDMINE_ISSUE_2_URL):<EOL><INDENT>body = issue_2_body<EOL><DEDENT>elif uri.startswith(REDMINE_ISSUE_5_URL):<EOL><INDENT>body = issue_5_body<EOL><DEDENT>elif uri.startswith(REDMINE_ISSUE_9_URL):<EOL><INDENT>body = issue_9_body<EOL><DEDENT>elif uri.startswith(REDMINE_ISSUE_7311_URL):<EOL><INDENT>if failures > <NUM_LIT:0>:<EOL><INDENT>status = <NUM_LIT><EOL>body = "<STR_LIT>"<EOL>failures -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>body = issue_7311_body<EOL><DEDENT><DEDENT>elif uri.startswith(REDMINE_USER_3_URL):<EOL><INDENT>body = user_3_body<EOL><DEDENT>elif uri.startswith(REDMINE_USER_4_URL):<EOL><INDENT>body = user_4_body<EOL><DEDENT>elif uri.startswith(REDMINE_USER_24_URL):<EOL><INDENT>body = user_24_body<EOL><DEDENT>elif uri.startswith(REDMINE_USER_25_URL):<EOL><INDENT>body = user_25_body<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT>http_requests.append(last_request)<EOL>return (status, headers, body)<EOL><DEDENT>for url in REDMINE_URL_LIST:<EOL><INDENT>httpretty.register_uri(httpretty.GET,<EOL>url,<EOL>responses=[<EOL>httpretty.Response(body=request_callback)<EOL>])<EOL><DEDENT>return http_requests<EOL>
Setup a mock Redmine HTTP server