Exemple #1
0
 def test_form_with_duplicate_names(self):
     environ = {
         'wsgi.input': io.BytesIO(b'a=foo&b=bar&a=baz'),
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '17',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {'a': ['foo', 'baz'], 'b': ['bar']})
Exemple #2
0
 def test_form_with_missing_value(self):
     environ = {
         'wsgi.input': io.BytesIO(b'a=foo&b='),
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '8',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {'a': ['foo']})
Exemple #3
0
 def test_form_with_excess_data(self):
     environ = {
         'wsgi.input': io.BytesIO(b'a=foo&b=bar'),
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '4',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {'a': ['fo']})
Exemple #4
0
 def test_form_with_percent_encoding(self):
     environ = {
         'wsgi.input': io.BytesIO(b'a=f%6f%6f&b=bar'),
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '15',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {'a': ['foo'], 'b': ['bar']})
Exemple #5
0
 def test_form_with_no_data(self):
     environ = {
         'wsgi.input': None,
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '0',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {})
Exemple #6
0
 def test_form_with_plus_sign(self):
     environ = {
         'wsgi.input': io.BytesIO(b'a=foo+bar&b=baz'),
         'REQUEST_METHOD': 'POST',
         'CONTENT_LENGTH': '15',
     }
     r = ice.Request(environ)
     self.assertEqual(r.form.data, {'a': ['foo bar'], 'b': ['baz']})
Exemple #7
0
 def test_query_with_plus_sign(self):
     r = ice.Request({'QUERY_STRING': 'a=foo+bar&b=baz'})
     self.assertEqual(r.query.data, {'a': ['foo bar'], 'b': ['baz']})
Exemple #8
0
 def test_query_with_no_query_string(self):
     r = ice.Request({})
     self.assertEqual(r.query.data, {})
Exemple #9
0
 def test_query_with_no_data(self):
     r = ice.Request({'QUERY_STRING': ''})
     self.assertEqual(r.query.data, {})
Exemple #10
0
 def test_query_with_missing_value(self):
     r = ice.Request({'QUERY_STRING': 'a=foo&b='})
     self.assertEqual(r.query.data, {'a': ['foo']})
Exemple #11
0
 def test_query_with_duplicate_names(self):
     r = ice.Request({'QUERY_STRING': 'a=foo&b=bar&a=baz'})
     self.assertEqual(r.query.data, {'a': ['foo', 'baz'], 'b': ['bar']})
Exemple #12
0
 def test_empty_path(self):
     r = ice.Request({'PATH_INFO': ''})
     self.assertEqual(r.path, '/')
Exemple #13
0
 def test_missing_method(self):
     r = ice.Request({})
     self.assertEqual(r.method, 'GET')
Exemple #14
0
 def test_method(self):
     r = ice.Request({'REQUEST_METHOD': 'HEAD'})
     self.assertEqual(r.method, 'HEAD')
Exemple #15
0
 def test_environ(self):
     r = ice.Request({'foo': 'bar'})
     self.assertEqual(r.environ, {'foo': 'bar'})
Exemple #16
0
 def test_cookies(self):
     environ = {'HTTP_COOKIE': 'a=foo; b="bar"; c="baz qux"'}
     r = ice.Request(environ)
     self.assertEqual(r.cookies, {'a': 'foo', 'b': 'bar', 'c': 'baz qux'})
Exemple #17
0
 def test_query_with_percent_encoding(self):
     r = ice.Request({'QUERY_STRING': 'a=f%6f%6f&b=bar'})
     self.assertEqual(r.query.data, {'a': ['foo'], 'b': ['bar']})
Exemple #18
0
 def test_missing_path(self):
     r = ice.Request({})
     self.assertEqual(r.path, '/')
Exemple #19
0
 def test_path(self):
     r = ice.Request({'PATH_INFO': '/foo'})
     self.assertEqual(r.path, '/foo')
Exemple #20
0
 def test_form_with_no_wsgi_input(self):
     r = ice.Request({'REQUEST_METHOD': 'POST'})
     self.assertEqual(r.form.data, {})