web/test/unittest_urlrewrite.py
changeset 3465 01616e5fa590
parent 3185 bd0126d17e83
child 4252 6c4f109c2b03
--- a/web/test/unittest_urlrewrite.py	Thu Sep 24 20:31:23 2009 +0200
+++ b/web/test/unittest_urlrewrite.py	Thu Sep 24 20:39:08 2009 +0200
@@ -13,7 +13,7 @@
 from cubicweb.web.views.urlrewrite import SimpleReqRewriter, SchemaBasedRewriter, rgx, rgx_action
 
 
-class UrlRewriteTC(TestCase):
+class UrlRewriteTC(CubicWebTC):
 
     def test_auto_extend_rules(self):
         class Rewriter(SimpleReqRewriter):
@@ -64,8 +64,8 @@
 
     def test_basic_transformation(self):
         """test simple string-based rewrite"""
-        rewriter = SimpleReqRewriter()
         req = FakeRequest()
+        rewriter = SimpleReqRewriter(req)
         self.assertRaises(KeyError, rewriter.rewrite, req, '/view?vid=whatever')
         self.assertEquals(req.form, {})
         rewriter.rewrite(req, '/index')
@@ -73,8 +73,8 @@
 
     def test_regexp_transformation(self):
         """test regexp-based rewrite"""
-        rewriter = SimpleReqRewriter()
         req = FakeRequest()
+        rewriter = SimpleReqRewriter(req)
         rewriter.rewrite(req, '/add/Task')
         self.assertEquals(req.form, {'vid' : "creation", 'etype' : "Task"})
         req = FakeRequest()
@@ -100,8 +100,8 @@
                                                                              transforms={'sn' : unicode.capitalize,
                                                                                          'fn' : unicode.lower,})),
                 ]
-        rewriter = TestSchemaBasedRewriter()
         req = self.request()
+        rewriter = TestSchemaBasedRewriter(req)
         pmid, rset = rewriter.rewrite(req, u'/DaLToN/JoE')
         self.assertEquals(len(rset), 1)
         self.assertEquals(rset[0][0], self.p1.eid)
@@ -125,8 +125,8 @@
                 ),
                 ]
 
-        rewriter = Rewriter()
         req = self.request()
+        rewriter = Rewriter(req)
         pmid, rset = rewriter.rewrite(req, '/collector')
         self.assertEquals(rset.rql, RQL1)
         self.assertEquals(req.form, {'vid' : "baseindex"})
@@ -159,8 +159,8 @@
                 ),
                 ]
 
-        rewriter = Rewriter()
         req = self.request()
+        rewriter = Rewriter(req)
         pmid, rset = rewriter.rewrite(req, '/collector')
         self.assertEquals(rset.rql, RQL2)
         self.assertEquals(req.form, {'vid' : "index"})