[test] test can_use_rest_path directly stable
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 04 Oct 2013 15:29:20 +0200
branchstable
changeset 9319 a68b8f423a8b
parent 9318 5d5b3a865eb1
child 9323 29d2f15cf596
[test] test can_use_rest_path directly No need to go through the Entity.rest_path if what we want is to unittest that one function.
test/unittest_entity.py
--- a/test/unittest_entity.py	Thu Sep 26 10:46:37 2013 +0200
+++ b/test/unittest_entity.py	Fri Oct 04 15:29:20 2013 +0200
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -26,6 +26,7 @@
 from cubicweb import Binary, Unauthorized
 from cubicweb.devtools.testlib import CubicWebTC
 from cubicweb.mttransforms import HAS_TAL
+from cubicweb.entity import can_use_rest_path
 from cubicweb.entities import fetch_config
 from cubicweb.uilib import soup2xhtml
 from cubicweb.schema import RQLVocabularyConstraint, RRQLExpression
@@ -695,14 +696,13 @@
         # unique attr with None value (nom in this case)
         friend = req.create_entity('Ami', prenom=u'bob')
         self.assertEqual(friend.rest_path(), unicode(friend.eid))
+
+    def test_can_use_rest_path(self):
+        self.assertTrue(can_use_rest_path(u'zobi'))
         # don't use rest if we have /, ? or & in the path (breaks mod_proxy)
-        person3 = req.create_entity('Personne', nom=u'zo/bi')
-        self.assertEqual(person3.rest_path(), unicode(person3.eid))
-        person4 = req.create_entity('Personne', nom=u'zo&bi')
-        self.assertEqual(person4.rest_path(), unicode(person4.eid))
-        person5 = req.create_entity('Personne', nom=u'zo?bi')
-        self.assertEqual(person5.rest_path(), unicode(person5.eid))
-
+        self.assertFalse(can_use_rest_path(u'zo/bi'))
+        self.assertFalse(can_use_rest_path(u'zo&bi'))
+        self.assertFalse(can_use_rest_path(u'zo?bi'))
 
     def test_cw_set_attributes(self):
         req = self.request()