From e17eacd8d77c78daa88d8f89ace990463378d98d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 14 Apr 2015 13:45:38 +1200 Subject: New get_cookie and set_cookie implementations for HTTPRequest --- test/test_protocol_http.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'test') 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: -- cgit v1.2.3