diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 13:45:38 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-14 13:45:38 +1200 |
commit | e17eacd8d77c78daa88d8f89ace990463378d98d (patch) | |
tree | 108943aae84446545c519826b965e0b557a2abc2 /test | |
parent | 4652887786db3da5facfb388ab0b673d67064ae5 (diff) | |
download | mitmproxy-e17eacd8d77c78daa88d8f89ace990463378d98d.tar.gz mitmproxy-e17eacd8d77c78daa88d8f89ace990463378d98d.tar.bz2 mitmproxy-e17eacd8d77c78daa88d8f89ace990463378d98d.zip |
New get_cookie and set_cookie implementations for HTTPRequest
Diffstat (limited to 'test')
-rw-r--r-- | test/test_protocol_http.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index 6b949ce3..11ab503b 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -161,7 +161,7 @@ class TestHTTPRequest: h = odict.ODictCaseless() r = tutils.treq() r.headers = h - assert r.get_cookies() is None + assert len(r.get_cookies()) == 0 def test_get_cookies_single(self): h = odict.ODictCaseless() @@ -170,7 +170,7 @@ class TestHTTPRequest: r.headers = h result = r.get_cookies() assert len(result)==1 - assert result['cookiename']==('cookievalue',{}) + assert result['cookiename']==['cookievalue'] def test_get_cookies_double(self): h = odict.ODictCaseless() @@ -179,8 +179,8 @@ class TestHTTPRequest: r.headers = h result = r.get_cookies() assert len(result)==2 - assert result['cookiename']==('cookievalue',{}) - assert result['othercookiename']==('othercookievalue',{}) + assert result['cookiename']==['cookievalue'] + assert result['othercookiename']==['othercookievalue'] def test_get_cookies_withequalsign(self): h = odict.ODictCaseless() @@ -189,10 +189,18 @@ class TestHTTPRequest: r.headers = h result = r.get_cookies() assert len(result)==2 - assert result['cookiename']==('coo=kievalue',{}) - assert result['othercookiename']==('othercookievalue',{}) - + assert result['cookiename']==['coo=kievalue'] + assert result['othercookiename']==['othercookievalue'] + def test_set_cookies(self): + h = odict.ODictCaseless() + h["Cookie"] = ["cookiename=cookievalue"] + r = tutils.treq() + r.headers = h + result = r.get_cookies() + result["cookiename"] = ["foo"] + r.set_cookies(result) + assert r.get_cookies()["cookiename"] == ["foo"] class TestHTTPResponse: |