From ccd8e1e617cdbf3b34ec01ac130093396197101f Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Fri, 24 Feb 2017 22:39:16 +0100 Subject: [PATCH] http: coverage++ (#2060) --- setup.cfg | 2 -- test/mitmproxy/test_http.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6ae4e0a75..634b7a958 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,7 +39,6 @@ exclude = mitmproxy/controller.py mitmproxy/export.py mitmproxy/flow.py - mitmproxy/http.py mitmproxy/io_compat.py mitmproxy/master.py mitmproxy/optmanager.py @@ -63,7 +62,6 @@ exclude = mitmproxy/exceptions.py mitmproxy/export.py mitmproxy/flow.py - mitmproxy/http.py mitmproxy/io.py mitmproxy/io_compat.py mitmproxy/log.py diff --git a/test/mitmproxy/test_http.py b/test/mitmproxy/test_http.py index 2423535d8..889eb0a7a 100644 --- a/test/mitmproxy/test_http.py +++ b/test/mitmproxy/test_http.py @@ -21,6 +21,7 @@ class TestHTTPRequest: assert r.url == u r2 = r.copy() assert r.get_state() == r2.get_state() + assert hash(r) def test_get_url(self): r = http.HTTPRequest.wrap(mitmproxy.test.tutils.treq()) @@ -95,6 +96,7 @@ class TestHTTPFlow: def test_copy(self): f = tflow.tflow(resp=True) + assert repr(f) f.get_state() f2 = f.copy() a = f.get_state() @@ -229,3 +231,26 @@ class TestHTTPFlow: assert f.response.raw_content != b"abarb" f.response.decode() assert f.response.raw_content == b"abarb" + + +def test_make_error_response(): + resp = http.make_error_response(543, 'foobar', Headers()) + assert resp + + +def test_make_connect_request(): + req = http.make_connect_request(('invalidhost', 1234)) + assert req.first_line_format == 'authority' + assert req.method == 'CONNECT' + assert req.http_version == 'HTTP/1.1' + + +def test_make_connect_response(): + resp = http.make_connect_response('foobar') + assert resp.http_version == 'foobar' + assert resp.status_code == 200 + + +def test_expect_continue_response(): + assert http.expect_continue_response.http_version == 'HTTP/1.1' + assert http.expect_continue_response.status_code == 100