def setup_http_server():
http_requests = []<EOL>modules_bodies = [<EOL>read_file('<STR_LIT>', '<STR_LIT:rb>'),<EOL>read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>]<EOL>ceph_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>nomad_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>empty_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>norisnetwork_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>sshuyskiy_body = read_file('<STR_LIT>', '<STR_LIT:rb>')<EOL>def request_callback(method, uri, headers):<EOL><INDENT>last_request = httpretty.last_request()<EOL>if uri.startswith(PUPPET_FORGE_MODULES_URL):<EOL><INDENT>body = modules_bodies.pop(<NUM_LIT:0>)<EOL><DEDENT>elif uri.startswith(PUPPET_FORGE_RELEASES_URL):<EOL><INDENT>params = last_request.querystring<EOL>module = params['<STR_LIT>'][<NUM_LIT:0>]<EOL>if module == '<STR_LIT>':<EOL><INDENT>body = ceph_body<EOL><DEDENT>elif module == '<STR_LIT>':<EOL><INDENT>body = nomad_body<EOL><DEDENT>else:<EOL><INDENT>body = empty_body<EOL><DEDENT><DEDENT>elif uri.startswith(PUPPET_FORGE_USER_NORISNETWORK_URL):<EOL><INDENT>body = norisnetwork_body<EOL><DEDENT>elif uri.startswith(PUPPET_FORGE_USER_SSHUYSKIY_URL):<EOL><INDENT>body = sshuyskiy_body<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT>http_requests.append(last_request)<EOL>return (<NUM_LIT:200>, headers, body)<EOL><DEDENT>httpretty.register_uri(httpretty.GET,<EOL>PUPPET_FORGE_MODULES_URL,<EOL>responses=[<EOL>httpretty.Response(body=request_callback)<EOL>for _ in range(<NUM_LIT:2>)<EOL>])<EOL>httpretty.register_uri(httpretty.GET,<EOL>PUPPET_FORGE_RELEASES_URL,<EOL>responses=[<EOL>httpretty.Response(body=request_callback)<EOL>for _ in range(<NUM_LIT:1>)<EOL>])<EOL>httpretty.register_uri(httpretty.GET,<EOL>PUPPET_FORGE_USER_NORISNETWORK_URL,<EOL>responses=[<EOL>httpretty.Response(body=request_callback)<EOL>for _ in range(<NUM_LIT:1>)<EOL>])<EOL>httpretty.register_uri(httpretty.GET,<EOL>PUPPET_FORGE_USER_SSHUYSKIY_URL,<EOL>responses=[<EOL>httpretty.Response(body=request_callback)<EOL>for _ in range(<NUM_LIT:1>)<EOL>])<EOL>return http_requests<EOL>
Setup a mock HTTP server