web/test/unittest_application.py
branchstable
changeset 5584 c1823448f81d
parent 5426 0d4853a6e5ee
child 6340 470d8e828fda
equal deleted inserted replaced
5583:24125df012f3 5584:c1823448f81d
     1 # -*- coding: iso-8859-1 -*-
       
     2 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     4 #
     3 #
     5 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     6 #
     5 #
    14 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    15 # details.
    14 # details.
    16 #
    15 #
    17 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    19 """unit tests for cubicweb.web.application
    18 """unit tests for cubicweb.web.application"""
    20 
       
    21 """
       
    22 
    19 
    23 import base64, Cookie
    20 import base64, Cookie
    24 import sys
    21 import sys
    25 from urllib import unquote
    22 from urllib import unquote
    26 
    23 
    27 from logilab.common.testlib import TestCase, unittest_main
    24 from logilab.common.testlib import TestCase, unittest_main
    28 from logilab.common.decorators import clear_cache
    25 from logilab.common.decorators import clear_cache
    29 
    26 
    30 from cubicweb import AuthenticationError
    27 from cubicweb import AuthenticationError, Unauthorized
    31 from cubicweb.devtools.testlib import CubicWebTC
    28 from cubicweb.devtools.testlib import CubicWebTC
    32 from cubicweb.devtools.fake import FakeRequest
    29 from cubicweb.devtools.fake import FakeRequest
    33 from cubicweb.web import LogOut, Redirect, INTERNAL_FIELD_VALUE
    30 from cubicweb.web import LogOut, Redirect, INTERNAL_FIELD_VALUE
    34 from cubicweb.web.views.basecontrollers import ViewController
    31 from cubicweb.web.views.basecontrollers import ViewController
    35 
    32 
   297         self.execute('DELETE CWProperty X WHERE X pkey "ui.language"')
   294         self.execute('DELETE CWProperty X WHERE X pkey "ui.language"')
   298         self.assertEquals(vreg.property_value('ui.language'), 'de')
   295         self.assertEquals(vreg.property_value('ui.language'), 'de')
   299         self.commit()
   296         self.commit()
   300         self.assertEquals(vreg.property_value('ui.language'), 'en')
   297         self.assertEquals(vreg.property_value('ui.language'), 'en')
   301 
   298 
       
   299     def test_login_not_available_to_authenticated(self):
       
   300         req = self.request()
       
   301         ex = self.assertRaises(Unauthorized, self.app_publish, req, 'login')
       
   302         self.assertEquals(str(ex), 'log out first')
       
   303 
   302     def test_fb_login_concept(self):
   304     def test_fb_login_concept(self):
   303         """see data/views.py"""
   305         """see data/views.py"""
   304         self.set_option('auth-mode', 'cookie')
   306         self.set_option('auth-mode', 'cookie')
   305         self.set_option('anonymous-user', 'anon')
   307         self.set_option('anonymous-user', 'anon')
   306         self.login('anon')
   308         self.login('anon')