wsgi/test/unittest_wsgi.py
changeset 9995 c9f1111e0ee8
parent 9988 623707a0c404
child 10670 96380c1524b0
equal deleted inserted replaced
9994:12a97d1c6015 9995:c9f1111e0ee8
     4 from StringIO import StringIO
     4 from StringIO import StringIO
     5 
     5 
     6 from cubicweb.devtools.webtest import CubicWebTestTC
     6 from cubicweb.devtools.webtest import CubicWebTestTC
     7 
     7 
     8 from cubicweb.wsgi.request import CubicWebWsgiRequest
     8 from cubicweb.wsgi.request import CubicWebWsgiRequest
       
     9 from cubicweb.multipart import MultipartError
     9 
    10 
    10 
    11 
    11 class WSGIAppTC(CubicWebTestTC):
    12 class WSGIAppTC(CubicWebTestTC):
    12     def test_content_type(self):
    13     def test_content_type(self):
    13         r = webtest.app.TestRequest.blank('/', {'CONTENT_TYPE': 'text/plain'})
    14         r = webtest.app.TestRequest.blank('/', {'CONTENT_TYPE': 'text/plain'})
    64     def test_post(self):
    65     def test_post(self):
    65         self.webapp.post(
    66         self.webapp.post(
    66             '/',
    67             '/',
    67             params={'__login': self.admlogin, '__password': self.admpassword})
    68             params={'__login': self.admlogin, '__password': self.admpassword})
    68 
    69 
       
    70     def test_post_bad_form(self):
       
    71         with self.assertRaises(MultipartError):
       
    72             self.webapp.post(
       
    73                 '/',
       
    74                 params='badcontent',
       
    75                 headers={'Content-Type': 'multipart/form-data'})
       
    76 
       
    77     def test_post_non_form(self):
       
    78         self.webapp.post(
       
    79             '/',
       
    80             params='{}',
       
    81             headers={'Content-Type': 'application/json'})
       
    82 
    69     def test_get_multiple_variables(self):
    83     def test_get_multiple_variables(self):
    70         r = webtest.app.TestRequest.blank('/?arg=1&arg=2')
    84         r = webtest.app.TestRequest.blank('/?arg=1&arg=2')
    71         req = CubicWebWsgiRequest(r.environ, self.vreg)
    85         req = CubicWebWsgiRequest(r.environ, self.vreg)
    72 
    86 
    73         self.assertEqual([u'1', u'2'], req.form['arg'])
    87         self.assertEqual([u'1', u'2'], req.form['arg'])