Back to index

plone3  3.1.7
test_browserview.py
Go to the documentation of this file.
00001 # Copyright (c) 2005-2007
00002 # Authors: KSS Project Contributors (see docs/CREDITS.txt)
00003 #
00004 # This program is free software; you can redistribute it and/or modify
00005 # it under the terms of the GNU General Public License version 2 as published
00006 # by the Free Software Foundation.
00007 #
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License
00014 # along with this program; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00016 # 02111-1307, USA.
00017 
00018 import unittest
00019 from base import KSSViewTestCase
00020 
00021 class TestBrowserView(KSSViewTestCase):
00022     
00023     def test_attach_error(self):
00024         'Test if errors are attached properly'
00025         # just render any page
00026         context = self.folder
00027         view = context.restrictedTraverse('@@kss_view')
00028         self.assert_(view is not None)
00029         view.attach_error(err_type='TheError', err_value='the_<>message\n\n')
00030         response = view.request.response
00031         header = response.getHeader('x-ksscommands')
00032         self.assert_('the_&amp;lt;&amp;gt;message' in header)   # no < > in the message
00033         self.assert_('\n' not in header)   # no /n in the payload: would destroy the page
00034         self.assertEqual(header, '<?xml version="1.0"?> <kukit xmlns="http://www.kukit.org/commands/1.1"> <commands> \t<command name="error"> \t\t<param name="type">system</param> \t\t<param name="message">TheError: the_&amp;lt;&amp;gt;message  </param> \t</command> </commands> </kukit> ')
00035 
00036 def test_suite():
00037     suites = []
00038     suites.append(unittest.makeSuite(TestBrowserView))
00039     return unittest.TestSuite(suites)