Back to index

plone3  3.1.7
test_portal.py
Go to the documentation of this file.
00001 import unittest
00002 from plone.app.layout.globals.tests.base import GlobalsTestCase
00003 
00004 from plone.app.layout.navigation.root import getNavigationRoot
00005 from zope.i18n.locales import locales
00006 
00007 class TestPortalStateView(GlobalsTestCase):
00008     """Ensure that the basic redirector setup is successful.
00009     """
00010     
00011     def afterSetUp(self):
00012         self.view = self.folder.restrictedTraverse('@@plone_portal_state')
00013     
00014     def test_portal(self):
00015         self.assertEquals(self.view.portal(), self.portal)
00016         
00017     def test_portal_title(self):
00018         self.portal.title = 'My title'
00019         self.assertEquals(self.view.portal_title(), 'My title')
00020         
00021     def test_portal_url(self):
00022         self.assertEquals(self.view.portal_url(), self.portal.absolute_url())
00023                        
00024     def test_navigation_root_path(self):
00025         self.assertEquals(self.view.navigation_root_path(), getNavigationRoot(self.folder))
00026         
00027     def test_navigation_root_url(self):
00028         url = self.app.REQUEST.physicalPathToURL(getNavigationRoot(self.folder))
00029         self.assertEquals(self.view.navigation_root_url(), url)
00030 
00031     def test_default_language(self):
00032         self.portal.portal_properties.site_properties.default_language = 'no'
00033         self.assertEquals(self.view.default_language(), 'no')
00034         
00035     def test_language(self):
00036         self.app.REQUEST.set('LANGUAGE', 'no')
00037         self.assertEquals(self.view.language(), 'no')
00038         
00039     def test_locale(self):
00040         self.app.REQUEST.set('HTTP_ACCEPT_LANGUAGE', 'no')
00041         no = locales.getLocale('no', None, None)
00042         self.assertEquals(self.view.locale(), no)
00043         
00044     def test_is_rtl(self):
00045         self.app.REQUEST.set('HTTP_ACCEPT_LANGUAGE', 'no')
00046         self.assertEquals(self.view.is_rtl(), False)
00047         del self.app.REQUEST.__annotations__
00048         self.app.REQUEST.set('HTTP_ACCEPT_LANGUAGE', 'he')
00049         self.assertEquals(self.view.is_rtl(), True)
00050         
00051     def test_member(self):
00052         self.assertEquals(self.view.member(), self.portal.portal_membership.getAuthenticatedMember())
00053         
00054     def test_anonymous(self):
00055         self.assertEquals(self.view.anonymous(), False)
00056         self.logout()
00057         del self.app.REQUEST.__annotations__
00058         self.assertEquals(self.view.anonymous(), True)
00059         
00060     def test_friendly_types(self):
00061         self.portal.portal_properties.site_properties.types_not_searched = ('Document',)
00062         self.failIf('Document' in self.view.friendly_types())
00063 
00064 def test_suite():
00065     suite = unittest.TestSuite()
00066     suite.addTest(unittest.makeSuite(TestPortalStateView))
00067     return suite