# HG changeset patch # User Julien Cristau # Date 1380893360 -7200 # Node ID a68b8f423a8bd26330b1f70f846ced35e06899b3 # Parent 5d5b3a865eb18192fd473e8bd8b1f65417775928 [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. diff -r 5d5b3a865eb1 -r a68b8f423a8b 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()