[KSS-checkins] r42970 - in kukit/kss.core/trunk/kss/core: . pluginregistry pluginregistry/deprecated plugins/core plugins/effects tests
gotcha at codespeak.net
gotcha at codespeak.net
Wed May 9 21:19:11 CEST 2007
Author: gotcha
Date: Wed May 9 21:19:10 2007
New Revision: 42970
Added:
kukit/kss.core/trunk/kss/core/kssview.py
- copied, changed from r42951, kukit/kss.core/trunk/kss/core/azaxview.py
kukit/kss.core/trunk/kss/core/kssview.txt
- copied unchanged from r42951, kukit/kss.core/trunk/kss/core/azaxview.txt
kukit/kss.core/trunk/kss/core/tests/test_kssview.py
- copied, changed from r42951, kukit/kss.core/trunk/kss/core/tests/test_azaxview.py
kukit/kss.core/trunk/kss/core/tests/test_kssview_core.py
- copied unchanged from r42951, kukit/kss.core/trunk/kss/core/tests/test_azaxview_core.py
kukit/kss.core/trunk/kss/core/tests/test_kssview_functional.py
- copied, changed from r42919, kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py
Removed:
kukit/kss.core/trunk/kss/core/azaxview.py
kukit/kss.core/trunk/kss/core/azaxview.txt
kukit/kss.core/trunk/kss/core/tests/test_azaxview.py
kukit/kss.core/trunk/kss/core/tests/test_azaxview_core.py
kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py
Modified:
kukit/kss.core/trunk/kss/core/__init__.py
kukit/kss.core/trunk/kss/core/actionwrapper.py
kukit/kss.core/trunk/kss/core/configure.zcml
kukit/kss.core/trunk/kss/core/pluginregistry/configure.zcml
kukit/kss.core/trunk/kss/core/pluginregistry/deprecated/directives.py
kukit/kss.core/trunk/kss/core/pluginregistry/interfaces.py
kukit/kss.core/trunk/kss/core/pluginregistry/registry.py
kukit/kss.core/trunk/kss/core/plugins/core/commands.py
kukit/kss.core/trunk/kss/core/plugins/effects/commands.py
kukit/kss.core/trunk/kss/core/siteview.txt
Log:
death to azax, step 2
Modified: kukit/kss.core/trunk/kss/core/__init__.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/__init__.py (original)
+++ kukit/kss.core/trunk/kss/core/__init__.py Wed May 9 21:19:10 2007
@@ -27,14 +27,16 @@
mimetypes.types_map['.kkt'] = 'text/xml' # BBB legacy!
mimetypes.types_map['.kukit'] = 'text/xml'
-from kss.core.azaxview import KSSView, CommandSet
+from kss.core.kssview import KSSView, CommandSet
from kss.core.actionwrapper import KSSExplicitError, kssaction
from kss.core.unicode_quirks import force_unicode, KSSUnicodeError
from kss.core.interfaces import ICommandSet
# BBB
-from kss.core.azaxview import AzaxBaseView
+from kss.core.kssview import AzaxBaseView
from kss.core.actionwrapper import KssExplicitError
+import sys, kssview
+sys.modules['kss.core.azaxview'] = kssview
try:
import Products.Five
Modified: kukit/kss.core/trunk/kss/core/actionwrapper.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/actionwrapper.py (original)
+++ kukit/kss.core/trunk/kss/core/actionwrapper.py Wed May 9 21:19:10 2007
@@ -30,7 +30,7 @@
return value
- if KSSExplicitError is raised, a normal response is returned,
- containing a single command:error azax command.
+ containing a single command:error KSS command.
Let's say we have a class here - that is supposed to be a kss view.
Deleted: /kukit/kss.core/trunk/kss/core/azaxview.py
==============================================================================
--- /kukit/kss.core/trunk/kss/core/azaxview.py Wed May 9 21:19:10 2007
+++ (empty file)
@@ -1,177 +0,0 @@
-# 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.
-
-'''\
-AZAX Base view class
-
-All the implementations should create a specialization
-of this class when building their browser views.
-
-The policy is that a method should build up a command
-set on available methods and then return self.render().
-
-The default command set is implemented in the base class
-as well.
-'''
-
-import warnings
-
-try:
- from Products.Five import BrowserView
-except ImportError:
- from zope.publisher.browser import BrowserView
-
-from kss.core.commands import KSSCommands
-from kss.core.interfaces import IKSSView, ICommandSet
-from kss.core.pluginregistry.commandset import getRegisteredCommandSet
-
-from zope import component, interface, event
-from zope.interface.adapter import VerifyingAdapterRegistry
-from zope.component import getSiteManager
-from zope.component.globalregistry import BaseGlobalComponents
-from zope.component.interfaces import IComponentLookup, ComponentLookupError
-from zope.component.interfaces import IObjectEvent
-from zope.app.component.interfaces import ISite
-from zope.app.publication.zopepublication import BeforeTraverseEvent
-
-class SiteViewComponents(BaseGlobalComponents):
-
- def _init_registries(self):
- # This is why this class is needed: we can't work with a
- # regular AdapterRegistry because it wants to do funny things
- # with __bases__.
- self.adapters = VerifyingAdapterRegistry()
- self.utilities = VerifyingAdapterRegistry()
-
-class SiteView(BrowserView):
- """A browser view that is its own site
- """
- interface.implements(ISite)
-
- def __init__(self, context, request):
- super(SiteView, self).__init__(context, request)
-
- next = component.getSiteManager()
- self._sitemanager = SiteViewComponents('siteview')
- self._sitemanager.__bases__ = (next, )
-
- # On Five, we should wrap it in the acquisition context
- # see, if self has aq_parent, it is done obligatoraly
- try:
- self.context.aq_parent
- except AttributeError:
- # Zope3 - No problem.
- wrapped_view = self
- else:
- wrapped_view = self.__of__(self.context)
-
- # register object event handler
- self._sitemanager.registerHandler(wrapped_view._eventRedispatcher)
-
- # Zope 2.10 doesn't send BeforeTraverseEvents for all objects,
- # only the ones for which you explicitly enable a before traverse
- # hook available from Five.component. Hence, this view won't
- # become the current site when it's traversed. This is bad,
- # hopefully Zope 2.11 will fix this. For now, we'll just take
- # care of it ourselves...
- def __before_publishing_traverse__(self, obj, request):
- event.notify(BeforeTraverseEvent(self, request))
-
- # ISite interface
-
- def getSiteManager(self):
- return self._sitemanager
-
- def setSiteManager(self, sm):
- raise TypeError("Site manager of SiteView can't be changed.")
-
- @component.adapter(IObjectEvent)
- def _eventRedispatcher(self, event):
- """This works similar to zope.component.event.objectEventNotify:
- It dispatches object events to subscribers that listen to
- (object, view, event)."""
- adapters = component.subscribers((event.object, self, event), None)
- for adapter in adapters:
- pass # getting them does the work
-
-class KSSView(SiteView):
- """KSS view
-
- This allows setting up the content of the response, and then
- generate it out.
- """
- interface.implements(IKSSView)
-
- def __init__(self, context, request):
- super(KSSView, self).__init__(context, request)
- self._initcommands()
-
- def _initcommands(self):
- self.commands = KSSCommands()
-
- # XXX avoid weird acquisition behaviour in Zope 2... this should
- # go away when Five views aren't Acquisition objects anymore.
- def _set_context(self, context):
- self._context = [context]
- def _get_context(self):
- return self._context[0]
- context = property(_get_context, _set_context)
-
- def render(self):
- """Views can use this to return their command set."""
- return self.commands.render(self.request)
-
- def cancelRedirect(self):
- if self.request.RESPONSE.getStatus() in (302, 303):
- # Try to not redirect if requested
- self.request.RESPONSE.setStatus(200)
-
- def getCommands(self):
- return self.commands
-
- def getCommandSet(self, name):
- commandset = getRegisteredCommandSet(name)
- # return the adapted view
- return commandset.provides(self)
-
-class CommandSet:
- interface.implements(ICommandSet)
-
- def __init__(self, view):
- self.view = view
- self.context = self.view.context
- self.request = self.view.request
- self.commands = self.view.commands
-
- def getCommandSet(self, name):
- return self.view.getCommandSet(name)
-
-# BBB deprecated
-class AzaxBaseView(KSSView):
- def __init__(self, *args, **kw):
- message = "'AzaxBaseView' is deprecated," \
- "use 'KSSView' instead."
- warnings.warn(message, DeprecationWarning, 2)
- KSSView.__init__(self, *args, **kw)
-
-class AzaxViewAdapter(CommandSet):
- def __init__(self, *args, **kw):
- message = "'AzaxViewAdapter' is deprecated," \
- "use 'CommandSet' instead."
- warnings.warn(message, DeprecationWarning, 2)
- CommandSet.__init__(self, *args, **kw)
-
Deleted: /kukit/kss.core/trunk/kss/core/azaxview.txt
==============================================================================
--- /kukit/kss.core/trunk/kss/core/azaxview.txt Wed May 9 21:19:10 2007
+++ (empty file)
@@ -1,66 +0,0 @@
-====================
-KSS views and events
-====================
-
-When we make a change using Ajax calls we would like to update the
-browser page. This can be done by sending browser commands. Some part
-of the page may need to be update based on modifications.
-
-We don't want to handle all these modifications in our own code. An
-example of such a modification change would be changing the
-title. This should also update the navigation portlet.
-
-To make this work KSS views do something special. We will explain
-this by creating an example. The following will setup our enviroment
-and show that normal operation works.
-
- >>> from kss.core import KSSView
- >>> from zope import component
- >>> from zope.lifecycleevent import ObjectModifiedEvent
- >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
- >>> from zope.publisher.browser import TestRequest
- >>> from zope.publisher.http import HTTPResponse
- >>> from zope import event
-
- >>> from zope.app.folder import folder
- >>> myfolder = folder.rootFolder()
- >>> request = TestRequest()
- >>> request.RESPONSE = HTTPResponse()
-
-Now we will write our custom.
-
- >>> class SampleView(KSSView):
- ... def setTitle(self, title):
- ... self.context.title = title
- ... event.notify(ObjectModifiedEvent(self.context))
- ... return self.render()
-
- >>> view = SampleView(myfolder, request)
-
-Simulate traversal by making the view the current site:
-
- >>> from zope.app.component.hooks import setSite
- >>> setSite(view)
-
-Let's set a title:
-
- >>> view.setTitle("some title")
- []
-
-Now that we have shown that this will not generate any KSS commands
-we will register a handler. This handler will catch the object event
-and add some KSS commands.
-
- >>> @component.adapter(None, SampleView, IObjectModifiedEvent)
- ... def stuff_happend(object, view, event):
- ... view.getCommandSet('core').replaceInnerHTML(
- ... 'div.class', object.title)
- >>> component.provideHandler(stuff_happend)
-
-When we call the renderer now it should have some more data in it.
-
- >>> view = SampleView(myfolder, request)
- >>> setSite(view)
-
- >>> view.setTitle(u"some title")[0]['params']['html']
- u'some title'
Modified: kukit/kss.core/trunk/kss/core/configure.zcml
==============================================================================
--- kukit/kss.core/trunk/kss/core/configure.zcml (original)
+++ kukit/kss.core/trunk/kss/core/configure.zcml Wed May 9 21:19:10 2007
@@ -35,7 +35,7 @@
name="MochiKit.js"
/>
- <!-- Adapter for rendering the azax commands -->
+ <!-- Adapter used to render KSS commands -->
<adapter
for=".interfaces.IKSSCommands
zope.publisher.interfaces.browser.IBrowserRequest"
Copied: kukit/kss.core/trunk/kss/core/kssview.py (from r42951, kukit/kss.core/trunk/kss/core/azaxview.py)
==============================================================================
--- kukit/kss.core/trunk/kss/core/azaxview.py (original)
+++ kukit/kss.core/trunk/kss/core/kssview.py Wed May 9 21:19:10 2007
@@ -16,7 +16,7 @@
# 02111-1307, USA.
'''\
-AZAX Base view class
+KSS Base view class
All the implementations should create a specialization
of this class when building their browser views.
Modified: kukit/kss.core/trunk/kss/core/pluginregistry/configure.zcml
==============================================================================
--- kukit/kss.core/trunk/kss/core/pluginregistry/configure.zcml (original)
+++ kukit/kss.core/trunk/kss/core/pluginregistry/configure.zcml Wed May 9 21:19:10 2007
@@ -12,13 +12,13 @@
<utility
provides="concatresource.interfaces.IConcatResourceAddon"
name="kukit.js"
- component=".registry.azaxConcatResourceAddon"
+ component=".registry.kssConcatResourceAddon"
/>
<utility
provides="concatresource.interfaces.IConcatResourceAddon"
name="kukit-src.js"
- component=".registry.azaxConcatResourceAddon"
+ component=".registry.kssConcatResourceAddon"
/>
</configure>
Modified: kukit/kss.core/trunk/kss/core/pluginregistry/deprecated/directives.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/pluginregistry/deprecated/directives.py (original)
+++ kukit/kss.core/trunk/kss/core/pluginregistry/deprecated/directives.py Wed May 9 21:19:10 2007
@@ -4,7 +4,7 @@
GlobalInterface
class IRegisterCommandDirective(Interface):
- 'Register an AZAX command plugin'
+ 'Register a KSS command plugin'
name = TextLine(
title=u"Name",
Modified: kukit/kss.core/trunk/kss/core/pluginregistry/interfaces.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/pluginregistry/interfaces.py (original)
+++ kukit/kss.core/trunk/kss/core/pluginregistry/interfaces.py Wed May 9 21:19:10 2007
@@ -18,7 +18,7 @@
from zope.interface import Interface
class IKSSPlugin(Interface):
- '''Base for azax plugins
+ '''Base for KSS plugins
this represents an entity implemented in a javascript file
'''
Modified: kukit/kss.core/trunk/kss/core/pluginregistry/registry.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/pluginregistry/registry.py (original)
+++ kukit/kss.core/trunk/kss/core/pluginregistry/registry.py Wed May 9 21:19:10 2007
@@ -40,4 +40,4 @@
files.append(plugin.jsfile)
return files
-azaxConcatResourceAddon = KSSConcatResourceAddon()
+kssConcatResourceAddon = KSSConcatResourceAddon()
Modified: kukit/kss.core/trunk/kss/core/plugins/core/commands.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/plugins/core/commands.py (original)
+++ kukit/kss.core/trunk/kss/core/plugins/core/commands.py Wed May 9 21:19:10 2007
@@ -1,6 +1,6 @@
from kss.core.selectors import Selector, CssSelector, HtmlIdSelector
from kss.core.selectors import ParentNodeSelector, SameNodeSelector
-from kss.core.azaxview import CommandSet
+from kss.core.kssview import CommandSet
from kss.core.deprecated import deprecated
from kss.core.parsers import HtmlParser
from kss.core.plugins.core.interfaces import IKSSCoreCommands
Modified: kukit/kss.core/trunk/kss/core/plugins/effects/commands.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/plugins/effects/commands.py (original)
+++ kukit/kss.core/trunk/kss/core/plugins/effects/commands.py Wed May 9 21:19:10 2007
@@ -16,7 +16,7 @@
# 02111-1307, USA.
from interfaces import IScriptaculousEffectsCommands
-from kss.core.azaxview import CommandSet
+from kss.core.kssview import CommandSet
class ScriptaculousEffectsCommands(CommandSet):
Modified: kukit/kss.core/trunk/kss/core/siteview.txt
==============================================================================
--- kukit/kss.core/trunk/kss/core/siteview.txt (original)
+++ kukit/kss.core/trunk/kss/core/siteview.txt Wed May 9 21:19:10 2007
@@ -15,7 +15,7 @@
The main class which implements views with a site manager is ``SiteView``:
- >>> from kss.core.azaxview import SiteView
+ >>> from kss.core.kssview import SiteView
>>> from zope import component
>>> old_sitemanager = component.getSiteManager()
Deleted: /kukit/kss.core/trunk/kss/core/tests/test_azaxview.py
==============================================================================
--- /kukit/kss.core/trunk/kss/core/tests/test_azaxview.py Wed May 9 21:19:10 2007
+++ (empty file)
@@ -1,56 +0,0 @@
-# -*- coding: latin-1 -*-
-# 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 kss.core.interfaces import IKSSView, IKSSCommands
-from kss.core.plugins.core.interfaces import IKSSCoreCommands
-from kss.core.plugins.core.commands import KSSCoreCommands
-from kss.core.pluginregistry.interfaces import IAction, ICommandSet
-from kss.core.pluginregistry.action import Action
-from kss.core.pluginregistry.plugin import registerPlugin
-from kss.core.pluginregistry.commandset import CommandSet
-from kss.core.tests.commandinspector import CommandInspectorView
-
-import zope.component.event
-from zope.testing import doctest, cleanup
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.component.hooks import setHooks
-
-def setUpAjaxView(test=None):
- setHooks()
- zope.component.provideAdapter(CommandInspectorView,
- adapts=(IKSSCommands, IBrowserRequest))
- registerPlugin(Action, IAction, 'replaceInnerHTML', None,
- 'selector', 'html', [], None)
- zope.component.provideAdapter(KSSCoreCommands,
- adapts=(IKSSView,),
- provides=IKSSCoreCommands)
- registerPlugin(CommandSet, ICommandSet, 'core', IKSSCoreCommands)
-
-def tearDownAjaxView(test=None):
- cleanup.cleanUp()
-
-def test_suite():
- return unittest.TestSuite([
- doctest.DocTestSuite('kss.core.azaxview'),
- doctest.DocFileSuite('azaxview.txt',
- package='kss.core',
- setUp=setUpAjaxView,
- tearDown=tearDownAjaxView),
- ])
Deleted: /kukit/kss.core/trunk/kss/core/tests/test_azaxview_core.py
==============================================================================
--- /kukit/kss.core/trunk/kss/core/tests/test_azaxview_core.py Wed May 9 21:19:10 2007
+++ (empty file)
@@ -1,161 +0,0 @@
-# -*- coding: latin-1 -*-
-# 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
-import textwrap
-from kss.core import KSSUnicodeError
-from kss.core.tests.base import KSSViewTestCase
-from Testing.ZopeTestCase import FunctionalDocFileSuite
-
-class TestKSSViewCoreCommandSet(KSSViewTestCase):
-
- def test_empty(self):
- view = self.createView()
- commands = view.getCommands()
- self.assertEqual(len(commands), 0)
-
- def test_addCommand(self):
- view = self.createView()
- commands = view.getCommands()
- command = commands.addCommand('replaceInnerHTML', 'selector')
- self.assertEqual(len(commands), 1)
- self.assertEqual(command.getName(), 'replaceInnerHTML')
- self.assertEqual(command.getSelector(), 'selector')
- params = command.getParams()
- self.assertEqual(len(params), 0)
-
- # XXX since lxml is gone, the next cases are no problem anymore
- # Nevertheless, we test all these cases
-
- def _checkSetHtmlResult(self, content, content2=None):
- view = self.createView()
- view.getCommandSet('core').replaceInnerHTML('div.class', content)
- commands = view.getCommands()
- self.assertEqual(len(commands), 1)
- command = commands[0]
- self.assertEqual(command.getName(), 'replaceInnerHTML')
- self.assertEqual(command.getSelector(), 'div.class')
- params = command.getParams()
- self.assertEqual(len(params), 2)
- self.assertEqual(params[0].getName(), 'html')
- self.assertEqual(params[1].getName(), 'withKssSetup')
- if content2 == None:
- content2 = content
- self.assertEqual(params[0].getContent().encode('ascii', 'xmlcharrefreplace'), content2.encode('ascii', 'xmlcharrefreplace'))
-
- def test_replaceInnerHTMLTextPlusEntity(self):
- 'See if non breaking space entity works'
- ##self._checkSetHtmlResult(' ')
- # XXX we remove html named entities now
- self._checkSetHtmlResult(' ', ' ')
-
- def test_replaceInnerHTMLTextPlusEntityOthers(self):
- 'See if the other HTML entities work as well'
- # XXX we remove html named entities now
- self._checkSetHtmlResult('<p xmlns="http://www.w3.org/1999/xhtml">»Hello world!«</p>',
- '<p xmlns="http://www.w3.org/1999/xhtml">»Hello world!«</p>')
-
- def test_replaceInnerHTMLTextOnly(self):
- self._checkSetHtmlResult('new content')
-
- def test_replaceInnerHTMLTagOnly(self):
- self._checkSetHtmlResult('<p xmlns="http://www.w3.org/1999/xhtml">new_content</p>')
-
- def test_replaceInnerHTMLTagPlusText(self):
- self._checkSetHtmlResult('<p xmlns="http://www.w3.org/1999/xhtml">new_content</p>after')
-
- def test_replaceInnerHTMLTextTagPlusText(self):
- self._checkSetHtmlResult('before<p xmlns="http://www.w3.org/1999/xhtml">new_content</p>after')
-
- def test_setHtmlAcceptsUnicode(self):
- 'Test that it accepts unicode'
- self._checkSetHtmlResult(u'abcá')
-
- def test_setHtmlChecksForNonUnicode(self):
- 'Test that it does not accept non unicode (unless pure ascii)'
- self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abcá')
-
-class FTestKSSViewCoreCommandSet(KSSViewTestCase):
- 'Functional tests'
-
- def _wrapped_commands(self, inline):
- header = textwrap.dedent(u'''\
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:kukit="http://www.kukit.org/commands/1.0"><body>
- <kukit:commands>
- ''')
- footer = textwrap.dedent('''\
- </kukit:commands>
- </body></html>
- ''')
- return header + inline + footer
-
- def assertXMLEquals(self, a, b):
- self.assertEqual(a, b)
-
- def assertCommandsEqual(self, a, b):
- self.assertXMLEquals(a, self._wrapped_commands(b))
-
- def test_empty(self):
- view = self.createView()
- result = view.render()
- self.assertEquals(view.request.response.getHeader('content-type'), 'text/xml;charset=utf-8')
- self.assertCommandsEqual(result, '')
-
- def test_replaceInnerHTML(self):
- view = self.createView()
- view.getCommandSet('core').replaceInnerHTML('div.class', 'new content')
- result = view.render()
- awaited = u'''\
-<kukit:command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <kukit:param name="html">new content</kukit:param>
- <kukit:param name="withKssSetup">True</kukit:param>
-</kukit:command>
-'''
- self.assertCommandsEqual(result, awaited)
-
- def test_setCommandSet(self):
- view = self.createView()
- cs = view.getCommandSet('core')
- cs.replaceInnerHTML('div.class', 'new content')
- result = view.render()
- awaited = u'''\
-<kukit:command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <kukit:param name="html">new content</kukit:param>
- <kukit:param name="withKssSetup">True</kukit:param>
-</kukit:command>
-'''
- self.assertCommandsEqual(result, awaited)
-
-def afterSetUp(self):
- KSSViewTestCase.afterSetUp(self)
- self.setDebugRequest()
-
-
-def test_suite():
- suites = []
- suites.append(unittest.makeSuite(TestKSSViewCoreCommandSet))
- suites.append(unittest.makeSuite(FTestKSSViewCoreCommandSet))
- suites.append(FunctionalDocFileSuite('../actionwrapper.py',
- test_class=KSSViewTestCase,
- setUp=afterSetUp,
- tearDown=KSSViewTestCase.beforeTearDown.im_func))
- return unittest.TestSuite(suites)
Deleted: /kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py
==============================================================================
--- /kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py Wed May 9 21:19:10 2007
+++ (empty file)
@@ -1,83 +0,0 @@
-#
-# 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
-
-import Products.Five
-from Products.Five import zcml
-from Testing.ZopeTestCase import FunctionalDocTestSuite
-
-from zope import event, component
-from zope.testing.cleanup import cleanUp
-from zope.lifecycleevent import ObjectModifiedEvent
-from zope.app.component.hooks import getSite, setHooks
-
-from kss.core import KSSView
-
-class TestKSSView(KSSView):
-
- def __call__(self):
- self.messages = []
- if getSite() == self:
- self.messages.append("I'm the current site.")
- if component.getSiteManager() == self.getSiteManager():
- self.messages.append("I have the current site manager.")
- event.notify(ObjectModifiedEvent(self.context))
- return "\n".join(self.messages)
-
- at component.adapter(None, KSSView, ObjectModifiedEvent)
-def objectModifiedThruKSSView(obj, view, event):
- view.messages.append("Event subscriber was here.")
-
-def setUp(test=None):
- configure_zcml = '''\
- <configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- package="kss.core.tests.test_azaxview_functional">
- <browser:page
- for="*"
- name="testkssview"
- class=".TestKSSView"
- permission="zope.Public"
- />
- <subscriber handler=".objectModifiedThruKSSView" />
- </configure>'''
- zcml.load_config('configure.zcml', Products.Five)
- zcml.load_string(configure_zcml)
- setHooks()
-
-def tearDown(test=None):
- cleanUp()
-
-def ftest_kssview():
- """
- Let's verify that a KSSView actually is the current site when it's
- being traversed to. Also, let's make sure that if in the course
- of this view, an object event is fired, the view will dispatch to
- KSS-specific subscribers:
-
- >>> from Products.Five.testbrowser import Browser
- >>> browser = Browser('http://localhost:8080/testkssview')
- >>> print browser.contents
- I'm the current site.
- I have the current site manager.
- Event subscriber was here.
- """
-
-def test_suite():
- return unittest.TestSuite([
- FunctionalDocTestSuite(setUp=setUp, tearDown=tearDown),
- ])
Copied: kukit/kss.core/trunk/kss/core/tests/test_kssview.py (from r42951, kukit/kss.core/trunk/kss/core/tests/test_azaxview.py)
==============================================================================
--- kukit/kss.core/trunk/kss/core/tests/test_azaxview.py (original)
+++ kukit/kss.core/trunk/kss/core/tests/test_kssview.py Wed May 9 21:19:10 2007
@@ -48,8 +48,8 @@
def test_suite():
return unittest.TestSuite([
- doctest.DocTestSuite('kss.core.azaxview'),
- doctest.DocFileSuite('azaxview.txt',
+ doctest.DocTestSuite('kss.core.kssview'),
+ doctest.DocFileSuite('kssview.txt',
package='kss.core',
setUp=setUpAjaxView,
tearDown=tearDownAjaxView),
Copied: kukit/kss.core/trunk/kss/core/tests/test_kssview_functional.py (from r42919, kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py)
==============================================================================
--- kukit/kss.core/trunk/kss/core/tests/test_azaxview_functional.py (original)
+++ kukit/kss.core/trunk/kss/core/tests/test_kssview_functional.py Wed May 9 21:19:10 2007
@@ -46,7 +46,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
- package="kss.core.tests.test_azaxview_functional">
+ package="kss.core.tests.test_kssview_functional">
<browser:page
for="*"
name="testkssview"
More information about the Kukit-checkins
mailing list