@@ -24,12 +24,12 @@ def test_parse_query_string_method_should_return_two_params(self):
24
24
def test_get_request_query_params_method_should_return_two_params (self ):
25
25
request = "GET /?param_one=one¶m_two=two HTTP/1.1\r \n Host: localhost\r \n \r \n "
26
26
self .assertEqual (utils .get_request_query_params (request ), {"param_one" : "one" , "param_two" : "two" },
27
- "Should be 'param_one=one¶m_two= two' " )
27
+ "Should be result with two params " )
28
28
29
29
def test_get_request_post_params_method_should_return_two_params (self ):
30
30
request = "POST /post HTTP/1.1\r \n Host: localhost\r \n Content-Type: application/x-www-form-urlencoded\r \n Content-Length: 27\r \n \r \n param_one=one¶m_two=two"
31
31
self .assertEqual (utils .get_request_post_params (request ), {"param_one" : "one" , "param_two" : "two" },
32
- "Should be 'param_one=one¶m_two= two' " )
32
+ "Should be result with two params " )
33
33
34
34
def test_unquote_method_should_return_empty_string (self ):
35
35
self .assertEqual (utils .unquote ("" ), "" , "Should be empty string" )
@@ -40,8 +40,27 @@ def test_unquote_method_should_return_string(self):
40
40
def test_unquote_method_should_return_unquoted_string (self ):
41
41
self .assertEqual (utils .unquote (
42
42
"%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%20%D0%B8%20%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B5%20%25" ),
43
- "параметр и значение %" ,
44
- "Should be 'параметр и значение %'" )
43
+ "параметр и значение %" ,
44
+ "Should be 'параметр и значение %'" )
45
+
46
+ def test_get_cookies_method_should_return_param (self ):
47
+ request = "GET / HTTP/1.1\r \n Host: localhost\r \n Cookie:foo=bar"
48
+ self .assertEqual (utils .get_cookies (request ), {"foo" : "bar" }, "Should be result with one param" )
49
+
50
+ def test_get_cookies_method_should_return_two_params (self ):
51
+ request = "GET / HTTP/1.1\r \n Host: localhost\r \n Cookie:foo=bar; abc=def\r \n Content-Length: 4\r \n \r \n test"
52
+ self .assertEqual (utils .get_cookies (request ), {"foo" : "bar" , "abc" : "def" }, "Should be result with two params" )
53
+
54
+ def test_create_cookie_method_should_return_correct_cookie (self ):
55
+ name = "name"
56
+ value = "value"
57
+ path = "/"
58
+ domain = "localhost"
59
+ expires = "Sat, 01-Jan-2030 00:00:00 GMT"
60
+ utils .create_cookie (name , value , path , domain , expires )
61
+ self .assertEqual (utils .create_cookie (name , value , path , domain , expires ),
62
+ "Set-Cookie: name=value; path=/; domain=localhost; expires=Sat, 01-Jan-2030 00:00:00 GMT" ,
63
+ "Should be correct cookie header" )
45
64
46
65
47
66
if __name__ == "__main__" :
0 commit comments