Author: jmorliaguet
Date: Sat Apr  1 16:34:27 2006
New Revision: 2754

Added:
   cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt   
(contents, props changed)
   cpsskins/branches/jmo-perspectives/ftests/test_negotiation.py   (contents, 
props changed)
Modified:
   cpsskins/branches/jmo-perspectives/tests/setup.py
Log:

- began adding some tests for browser.negotiation



Added: cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt   Sat Apr 
 1 16:34:27 2006
@@ -0,0 +1,57 @@
+
+===========
+NEGOTIATION
+===========
+
+    >>> from zope.publisher.browser import TestRequest
+    >>> request = TestRequest()
+
+    >>> root = getRootFolder()
+    >>> from cpsskins.tests.setup import addThemeSkeleton, addThemeManager
+    >>> manager = addThemeManager(root)
+    >>> theme1 = addThemeSkeleton(manager, u'Theme 1')
+    >>> theme2 = addThemeSkeleton(manager, u'Theme 2')
+    >>> theme3 = addThemeSkeleton(manager, u'Theme 3')
+
+    >>> from zope.app import zapi
+    >>> from cpsskins.browser.negotiation.interfaces import INegotiation
+    >>> negotiation = zapi.getMultiAdapter((root, request), INegotiation,
+    ...                                    'negotiation')
+
+Themes
+------
+
+To obtain the theme as a result of the negotiation the 'getTheme' method is
+used.
+
+If nothing is specified, the default theme is returned:
+
+    >>> theme = negotiation.getTheme()
+    >>> theme.name
+    'Theme'
+
+    >>> manager.isDefault(theme)
+    True
+
+
+The theme's name can be specified in the URL, by writing ...?theme=Theme-2
+
+    >>> request.form[u'theme'] = u'Theme-2'
+    >>> theme = negotiation.getTheme()
+    >>> theme.name
+    u'Theme-2'
+
+    >>> del request.form[u'theme']
+
+
+The theme's name can also be specified in a cookie:
+
+    >>> request.response.setCookie('cpsskins_theme', u'Theme-3')
+    >>> theme = negotiation.getTheme()
+
+    TODO
+
+    >>> request.response.expireCookie('cpsskins_theme')
+
+
+

Added: cpsskins/branches/jmo-perspectives/ftests/test_negotiation.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/ftests/test_negotiation.py       Sat Apr 
 1 16:34:27 2006
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Format tests
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+
+from zope.app.testing.functional import FunctionalDocFileSuite
+from zope.app.testing import ztapi
+
+from cpsskins.browser.negotiation.interfaces import INegotiation
+from cpsskins.browser.negotiation.views import NegotiationView
+
+def setUp(test):
+    ztapi.provideView(None, None, INegotiation, 'negotiation', NegotiationView)
+
+def test_suite():
+    return unittest.TestSuite((
+        FunctionalDocFileSuite('../browser/negotiation/README.txt',
+                               setUp=setUp),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')

Modified: cpsskins/branches/jmo-perspectives/tests/setup.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/tests/setup.py   (original)
+++ cpsskins/branches/jmo-perspectives/tests/setup.py   Sat Apr  1 16:34:27 2006
@@ -65,8 +65,8 @@
     ztapi.provideUtility(IThemeManagementFolder, tmutil, name=u'themes')
     return tmutil
 
-def addThemeSkeleton(context):
-    theme = elements.theme.Theme('A theme')
+def addThemeSkeleton(context, title=u'A theme'):
+    theme = elements.theme.Theme(title)
     context.addTheme(theme)
     theme[u'page'] = elements.themepage.ThemePage('A page')
     theme[u'page'][u'block'] = elements.pageblock.PageBlock('A page block')
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to