aboutsummaryrefslogtreecommitdiffstats
path: root/test/http/test_exceptions.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-05 21:32:53 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-10 20:34:27 +0200
commit690b8b4f4e00d60b373b5a1481930f21bbc5054a (patch)
treedd0091035e4027e792174cb2dcf63eb37afa0a56 /test/http/test_exceptions.py
parentc2832ef72bd4eed485a1c8d4bcb732da69896444 (diff)
downloadmitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.tar.gz
mitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.tar.bz2
mitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.zip
add move tests and code from mitmproxy
Diffstat (limited to 'test/http/test_exceptions.py')
-rw-r--r--test/http/test_exceptions.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/test/http/test_exceptions.py b/test/http/test_exceptions.py
index aa57f831..0131c7ef 100644
--- a/test/http/test_exceptions.py
+++ b/test/http/test_exceptions.py
@@ -1,6 +1,27 @@
from netlib.http.exceptions import *
+from netlib import odict
-def test_HttpAuthenticationError():
- x = HttpAuthenticationError({"foo": "bar"})
- assert str(x)
- assert "foo" in x.headers
+class TestHttpError:
+ def test_simple(self):
+ e = HttpError(404, "Not found")
+ assert str(e)
+
+class TestHttpAuthenticationError:
+ def test_init(self):
+ headers = odict.ODictCaseless([("foo", "bar")])
+ x = HttpAuthenticationError(headers)
+ assert str(x)
+ assert isinstance(x.headers, odict.ODictCaseless)
+ assert x.code == 407
+ assert x.headers == headers
+ print(x.headers.keys())
+ assert "foo" in x.headers.keys()
+
+ def test_header_conversion(self):
+ headers = {"foo": "bar"}
+ x = HttpAuthenticationError(headers)
+ assert isinstance(x.headers, odict.ODictCaseless)
+ assert x.headers.lst == headers.items()
+
+ def test_repr(self):
+ assert repr(HttpAuthenticationError()) == "Proxy Authentication Required"