File: test_browserview.py

package info (click to toggle)
plone3 3.1.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 73,972 kB
  • ctags: 39,149
  • sloc: python: 209,481; xml: 25,065; sh: 1,395; makefile: 585; php: 129; lisp: 54
file content (39 lines) | stat: -rw-r--r-- 1,827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) 2005-2007
# Authors: KSS Project Contributors (see docs/CREDITS.txt)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

import unittest
from base import KSSViewTestCase

class TestBrowserView(KSSViewTestCase):
    
    def test_attach_error(self):
        'Test if errors are attached properly'
        # just render any page
        context = self.folder
        view = context.restrictedTraverse('@@kss_view')
        self.assert_(view is not None)
        view.attach_error(err_type='TheError', err_value='the_<>message\n\n')
        response = view.request.response
        header = response.getHeader('x-ksscommands')
        self.assert_('the_&amp;lt;&amp;gt;message' in header)   # no < > in the message
        self.assert_('\n' not in header)   # no /n in the payload: would destroy the page
        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> ')

def test_suite():
    suites = []
    suites.append(unittest.makeSuite(TestBrowserView))
    return unittest.TestSuite(suites)