Back to index

plone3  3.1.7
test_demoview.py
Go to the documentation of this file.
00001 # Copyright (c) 2005
00002 # Authors:
00003 #   Godefroid Chapelle <gotcha@bubblenet.be>
00004 #   Tarek Ziade <tz@nuxeo.com>
00005 #
00006 # This program is free software; you can redistribute it and/or modify
00007 # it under the terms of the GNU General Public License version 2 as published
00008 # by the Free Software Foundation.
00009 #
00010 # This program is distributed in the hope that it will be useful,
00011 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 # GNU General Public License for more details.
00014 #
00015 # You should have received a copy of the GNU General Public License
00016 # along with this program; if not, write to the Free Software
00017 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018 # 02111-1307, USA.
00019 #
00020 import unittest, os
00021 from zope.testing import doctest
00022 from Testing.ZopeTestCase import ZopeTestCase
00023 from kss.core.tests.base import KSSViewTestCase
00024 from Products.Five.zcml import load_string, load_config
00025 import kss.demo
00026 
00027 try:
00028     import Products.Five
00029 except AttributeError:
00030     from kss.demo.simplecontent_z3 import SimpleContent
00031 else:
00032     from kss.demo.simplecontent import SimpleContent
00033 
00034 class KSSDemoTestCase(KSSViewTestCase):
00035 
00036     class layer(KSSViewTestCase.layer):
00037         @classmethod
00038         def setUp(cls):
00039             load_config('meta.zcml', package=kss.demo)
00040             load_config('configure.zcml', package=kss.demo)
00041 
00042     def afterSetUp(self):
00043         KSSViewTestCase.afterSetUp(self)
00044         self.setDebugRequest()
00045         self.folder._setObject('demo', SimpleContent('Demo', 'Demo'))
00046         self.view = self.folder.demo.restrictedTraverse('getDivContent')
00047 
00048     def test_instantiation(self):
00049         view = self.view
00050         commands = view.getCommands()
00051         self.assertNotEquals(view, None)
00052 
00053     # XXX This shows the idea of how the commands output can be
00054     # tested by using DebugTestRequest. 
00055     def test_getDivContent(self):
00056         view = self.view
00057         commands = view.getCommands()
00058         res = view.getDivContent()
00059         self.assertEquals(res, [
00060             {'selectorType': '', 'params': {
00061                     'html': u'<![CDATA[<h1>it worked</h1>]]>',
00062                     'withKssSetup': u'True',
00063                 }, 'name': 'replaceInnerHTML', 'selector': 'div#demo'}, 
00064             {'selectorType': '', 'params': {
00065                     'html': u'<![CDATA[<h1 id="workedagain">it worked&#160;again</h1>]]>',
00066                     'withKssSetup': u'True',
00067                 }, 'name': 'replaceInnerHTML', 'selector': 'div#demo'},
00068             ])
00069 
00070 def test_suite():
00071     return unittest.TestSuite((
00072         unittest.makeSuite(KSSDemoTestCase),
00073         ))