Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1203: test_reponse.py

File test_reponse.py, 1.0 KB (added by Felix.Schwarz, 5 years ago)

some cleanup, removed wrong cherrypy.request assignments

Line 
1#!/usr/bin/env python
2# -*- coding: UTF-8 -*-
3
4import unittest
5
6import cherrypy
7import turbogears
8from turbogears import controllers, redirect, testutil
9
10class RedirectRoot(controllers.RootController):
11    def index(self):
12        raise redirect("foo")
13    index = turbogears.expose()(index)
14
15class TestControllers(unittest.TestCase):
16    def setUp(self):
17        cherrypy.root = None
18        cherrypy.tree.mount_points = {}
19        cherrypy.tree.mount(RedirectRoot(), "/")
20        self.root = cherrypy.root
21
22    def tearDown(self):
23        cherrypy.root = None
24        cherrypy.tree.mount_points = {}
25
26   
27    def test_index(self):
28        "Test that call_with_request is usable if controller uses redirect"
29        try:
30            testutil.call(self.root.index)
31            self.fail("no redirect exception raised")
32        except cherrypy.HTTPRedirect, e:
33            assert e.status in [302, 303]
34            self.assertEquals(1, len(e.urls))
35            assert e.urls[0].endswith("foo")
36
37if __name__ == "__main__":
38    unittest.main()