Esempio n. 1
0
 def test_send(self):
     view = BaseView(self.context2, self.request)
     self.assert_(
         view.SendResponse("the response",
                           mime="text/html",
                           raiseException=False,
                           filename=None))
     self.assert_(
         view.SendResponse("the response",
                           mime="text/html",
                           raiseException=False,
                           filename="file.html",
                           headers=[("X-Result", "true")]))
     self.assertRaises(ExceptionalResponse,
                       view.SendResponse,
                       "the response",
                       mime="text/html",
                       raiseException=True,
                       filename="file.html",
                       headers=[("X-Result", "true")])
     try:
         view.SendResponse("the response body",
                           mime="text/html",
                           raiseException=True,
                           headers=[("X-Result", "true")])
     except ExceptionalResponse, e:
         self.assert_(e.body == "the response body")
         self.assert_(e.status_int == 200)
         self.assert_(e.status == "200 OK")
         self.assert_(e.headers["X-Result"] == "true")
         self.assert_(e.headers["Content-Type"].startswith("text/html"))