[z3-checkins] r5143 - in z3/Five/trunk: . demo demo/FiveDemo
demo/FiveViewsDemo demo/FiveViewsDemo/www doc tests
tests/products tests/products/FiveTest tests/products/FiveTest/www
faassen at codespeak.net
faassen at codespeak.net
Thu Jun 17 11:30:48 MEST 2004
Author: faassen
Date: Thu Jun 17 11:30:48 2004
New Revision: 5143
Added:
z3/Five/trunk/tests/products/FiveTest/browser.py
z3/Five/trunk/tests/products/FiveTest/helpers.py
z3/Five/trunk/tests/products/FiveTest/simplecontent.py
z3/Five/trunk/tests/products/FiveTest/www/
z3/Five/trunk/tests/products/FiveTest/www/simpleContentAdd.zpt
Modified:
z3/Five/trunk/ (props changed)
z3/Five/trunk/demo/ (props changed)
z3/Five/trunk/demo/FiveDemo/ (props changed)
z3/Five/trunk/demo/FiveViewsDemo/ (props changed)
z3/Five/trunk/demo/FiveViewsDemo/www/ (props changed)
z3/Five/trunk/doc/ (props changed)
z3/Five/trunk/tests/ (props changed)
z3/Five/trunk/tests/products/ (props changed)
z3/Five/trunk/tests/products/FiveTest/ (props changed)
z3/Five/trunk/tests/products/FiveTest/__init__.py
z3/Five/trunk/tests/products/FiveTest/configure.zcml
z3/Five/trunk/tests/products/FiveTest/interfaces.py
z3/Five/trunk/tests/test_five.py
Log:
Add simple test for views.
Set property to ignore *.pyc files.
Modified: z3/Five/trunk/tests/products/FiveTest/__init__.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/__init__.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/__init__.py Thu Jun 17 11:30:48 2004
@@ -1,6 +1,12 @@
from Products.Five import zcml
import Products
+import simplecontent
def initialize(context):
zcml.process('configure.zcml', package=Products.FiveTest)
+ context.registerClass(
+ simplecontent.SimpleContent,
+ constructors = (simplecontent.manage_addSimpleContentForm,
+ simplecontent.manage_addSimpleContent),
+ )
Added: z3/Five/trunk/tests/products/FiveTest/browser.py
==============================================================================
--- (empty file)
+++ z3/Five/trunk/tests/products/FiveTest/browser.py Thu Jun 17 11:30:48 2004
@@ -0,0 +1,15 @@
+from AccessControl import ClassSecurityInfo
+from Globals import InitializeClass
+from Products.Five.api import BrowserView
+
+class SimpleContentView(BrowserView):
+ """More docstring. Please Zope"""
+ security = ClassSecurityInfo()
+
+ security.declareProtected('View Management Screens', 'eagle')
+ def eagle(self):
+ """Docstring"""
+ return "The eagle has landed"
+
+InitializeClass(SimpleContentView)
+
Modified: z3/Five/trunk/tests/products/FiveTest/configure.zcml
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/configure.zcml (original)
+++ z3/Five/trunk/tests/products/FiveTest/configure.zcml Thu Jun 17 11:30:48 2004
@@ -1,8 +1,16 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:five="http://namespaces.zope.org/five">
<adapter
for=".interfaces.IAdaptable"
provides=".interfaces.IAdapted"
factory=".classes.Adapter" />
-
+
+ <five:page
+ for=".interfaces.ISimpleContent"
+ class=".browser.SimpleContentView"
+ attribute="eagle"
+ name="eagle.txt"
+ />
+
</configure>
Added: z3/Five/trunk/tests/products/FiveTest/helpers.py
==============================================================================
--- (empty file)
+++ z3/Five/trunk/tests/products/FiveTest/helpers.py Thu Jun 17 11:30:48 2004
@@ -0,0 +1,16 @@
+import urllib
+
+def add_and_edit(self, id, REQUEST):
+ """Helper function to point to the object's management screen if
+ 'Add and Edit' button is pressed.
+ id -- id of the object we just added
+ """
+ if REQUEST is None:
+ return
+ try:
+ u = self.DestinationURL()
+ except:
+ u = REQUEST['URL1']
+ if REQUEST.has_key('submit_edit'):
+ u = "%s/%s" % (u, urllib.quote(id))
+ REQUEST.RESPONSE.redirect(u+'/manage_main')
Modified: z3/Five/trunk/tests/products/FiveTest/interfaces.py
==============================================================================
--- z3/Five/trunk/tests/products/FiveTest/interfaces.py (original)
+++ z3/Five/trunk/tests/products/FiveTest/interfaces.py Thu Jun 17 11:30:48 2004
@@ -15,3 +15,5 @@
"""A method to adapt.
"""
+class ISimpleContent(Interface):
+ pass
Added: z3/Five/trunk/tests/products/FiveTest/simplecontent.py
==============================================================================
--- (empty file)
+++ z3/Five/trunk/tests/products/FiveTest/simplecontent.py Thu Jun 17 11:30:48 2004
@@ -0,0 +1,35 @@
+from OFS.SimpleItem import SimpleItem
+from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
+from helpers import add_and_edit
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.Five.api import Viewable
+from zope.interface import implements
+from interfaces import ISimpleContent
+
+class SimpleContent(SimpleItem, Viewable):
+
+ implements(ISimpleContent)
+
+ meta_type = 'SimpleContent'
+ security = ClassSecurityInfo()
+
+ def __init__(self, id, title):
+ self.id = id
+ self.title = title
+
+ security.declarePublic('mymethod')
+ def mymethod(self):
+ return "Hello world"
+
+InitializeClass(SimpleContent)
+
+manage_addSimpleContentForm = PageTemplateFile(
+ "www/simpleContentAdd", globals(),
+ __name__ = 'manage_addSimpleContentForm')
+
+def manage_addSimpleContent(self, id, title, REQUEST=None):
+ """Add the simple content."""
+ id = self._setObject(id, SimpleContent(id, title))
+ add_and_edit(self, id, REQUEST)
+ return ''
Added: z3/Five/trunk/tests/products/FiveTest/www/simpleContentAdd.zpt
==============================================================================
--- (empty file)
+++ z3/Five/trunk/tests/products/FiveTest/www/simpleContentAdd.zpt Thu Jun 17 11:30:48 2004
@@ -0,0 +1,47 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+
+<h2 tal:define="form_title string:Add Silva SidebarService"
+ tal:replace="structure here/manage_form_title">Form Title</h2>
+
+<p class="form-help">
+Add Simple Content
+</p>
+
+<form action="manage_addSimpleContent" method="post">
+<table cellspacing="0" cellpadding="2" border="0">
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">
+ Id
+ </div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="id" size="40" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">
+ Title
+ </div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="title" size="40" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ </td>
+ <td align="left" valign="top">
+ <div class="form-element">
+ <input class="form-element" type="submit" name="submit_add"
+ value=" Add " />
+ <input class="form-element" type="submit" name="submit_edit"
+ value=" Add and Edit " />
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
Modified: z3/Five/trunk/tests/test_five.py
==============================================================================
--- z3/Five/trunk/tests/test_five.py (original)
+++ z3/Five/trunk/tests/test_five.py Thu Jun 17 11:30:48 2004
@@ -15,6 +15,7 @@
from zope.component import getAdapter
from Products.FiveTest.classes import Adaptable
from Products.FiveTest.interfaces import IAdapted
+from Products.FiveTest.browser import SimpleContentView
class FiveTestCase(ZopeTestCase.ZopeTestCase):
def beforeSetUp(self):
@@ -33,8 +34,17 @@
self.assertEquals(
"Adapted: The method",
adapted.adaptedMethod())
+
+ def test_view1(self):
+
+ self.root.manage_addProduct['FiveTest'].manage_addSimpleContent(
+ 'testoid', 'Testoid')
+ test = self.root.test
+ view = self.root.unrestrictedTraverse('testoid/eagle.txt')
+ self.assert_(isinstance(view, SimpleContentView))
+ data = view()
+ self.assertEquals('The eagle has landed', data)
-
if __name__ == '__main__':
framework()
else:
More information about the z3-checkins
mailing list