[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container/tests -
test_adding.py:1.17
Raju Sivalingam
sraju at zeomega.com
Wed Dec 10 02:44:46 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/container/tests
In directory cvs.zope.org:/tmp/cvs-serv10720
Modified Files:
test_adding.py
Log Message:
-- unit test for renderAddButton method.
-- added one more test case.
=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.16 Tue Dec 9 05:45:49 2003
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py Wed Dec 10 02:44:46 2003
@@ -40,6 +40,9 @@
from zope.app.interfaces.container import IWriteContainer
from zope.app.interfaces.container import IContainerNamesContainer
import zope.interface
+from zope.app.interfaces.container import INameChooser
+from zope.app.interfaces.container import IContainer
+from zope.app.browser.container.contents import Contents
class Root:
implements(IContainmentRoot)
@@ -116,7 +119,7 @@
provideFactory('fooprivate', Factory())
factory = Factory()
- factory.__Security_checker__ = zope.security.checker.NamesChecker(
+ factory.__Security_checker__ = zope.security.checker.NamesChecker(
['__call__'])
provideFactory('foo', factory)
@@ -256,26 +259,68 @@
"""
Test for renderAddButton in adding.py
+ >>> setUp()
>>> from zope.app.browser.container.adding import Adding
>>> from zope.app.interfaces.container import IContainerNamesContainer
+
+ Class implements IContainerNamesContainer
+
>>> class FakeContainer:
... zope.interface.implements(IContainerNamesContainer)
- >>> class Fake:
- ... pass
+ renderAddButton returns only 'Add' button if the class imlement
+ IContainerNamesContainer
+
>>> adding = Adding(FakeContainer(),TestRequest())
>>> adding.renderAddButton()
"<input type='submit' name='UPDATE_SUBMIT' value=' Add '>"
+
+ Fake class without IContainerNamesContainer
+
+ >>> class Fake:
+ ... pass
+
+ renderAddButton returns only 'Add' and 'inputbox' if the class
+ doest imlement IContainerNamesContainer
+
>>> adding = Adding(Fake(),TestRequest())
>>> adding.renderAddButton()
"<input type='submit' name='UPDATE_SUBMIT' value=' Add '>""" \
"""<input type='text' name='add_input_name' value=''>"
+
>>> adding.contentName='myname'
>>> adding.renderAddButton()
"<input type='submit' name='UPDATE_SUBMIT' value=' Add '>""" \
"""<input type='text' name='add_input_name' value='myname'>"
+ >>> adding = Adding(Fake(),TestRequest())
+
+ To check request variable
+
+ >>> from zope.app.interfaces.container import IContainer
+ >>> from zope.app.publisher.browser import BrowserView
+
+ >>> class MyContainer:
+ ... zope.interface.implements(INameChooser, IContainer)
+ ... def chooseName(self, name, object):
+ ... return "foo"
+ ... def checkName(self, name, object):
+ ... return "foo"
+ ... def __setitem__(self, name, object):
+ ... setattr(self, name, object)
+ ... def __getitem__(self, key):
+ ... return key
+
+ >>> request = TestRequest()
+ >>> request.form.update({'add_input_name': 'reqname'})
+ >>> mycontainer = MyContainer()
+ >>> adding = Adding(mycontainer, request)
+ >>> o = object()
+ >>> adding.add(o)
+ 'reqname'
+ >>> mycontainer.reqname is o
+ True
+ >>> tearDown()
- >>>
"""
More information about the Zope3-Checkins
mailing list