[Checkins] SVN: grokcore.component/trunk/src/grok/tests/ With
Robert Marianski, removed all unit tests that were not
Brandon Rhodes
brandon at rhodesmill.org
Mon Mar 17 16:24:13 EDT 2008
Log message for revision 84745:
With Robert Marianski, removed all unit tests that were not
appropriate from grokcore.component.
Changed:
D grokcore.component/trunk/src/grok/tests/annotation/
D grokcore.component/trunk/src/grok/tests/application/
D grokcore.component/trunk/src/grok/tests/baseclass/
D grokcore.component/trunk/src/grok/tests/catalog/
D grokcore.component/trunk/src/grok/tests/container/
D grokcore.component/trunk/src/grok/tests/error/
D grokcore.component/trunk/src/grok/tests/event/
D grokcore.component/trunk/src/grok/tests/form/
D grokcore.component/trunk/src/grok/tests/json/
D grokcore.component/trunk/src/grok/tests/security/
D grokcore.component/trunk/src/grok/tests/static/
D grokcore.component/trunk/src/grok/tests/template/
D grokcore.component/trunk/src/grok/tests/traversal/
D grokcore.component/trunk/src/grok/tests/utility/local_implementsmany.py
D grokcore.component/trunk/src/grok/tests/utility/local_implementsnone.py
D grokcore.component/trunk/src/grok/tests/utility/local_implementsnone2.py
D grokcore.component/trunk/src/grok/tests/utility/multiple_class.py
D grokcore.component/trunk/src/grok/tests/utility/multiple_directive.py
D grokcore.component/trunk/src/grok/tests/utility/publicnoncontainer.py
D grokcore.component/trunk/src/grok/tests/view/ambiguouscontext.py
D grokcore.component/trunk/src/grok/tests/view/dirandinlinetemplate.py
D grokcore.component/trunk/src/grok/tests/view/dirandinlinetemplate_templates/
D grokcore.component/trunk/src/grok/tests/view/dirtemplate.py
D grokcore.component/trunk/src/grok/tests/view/dirtemplate_templates/
D grokcore.component/trunk/src/grok/tests/view/dirtemplateandrender.py
D grokcore.component/trunk/src/grok/tests/view/dirtemplateandrender_templates/
D grokcore.component/trunk/src/grok/tests/view/dirtemplatesonly.py
D grokcore.component/trunk/src/grok/tests/view/dirtemplatesonly_templates/
D grokcore.component/trunk/src/grok/tests/view/eithertemplateorrender.py
D grokcore.component/trunk/src/grok/tests/view/explicitimplicittemplate.py
D grokcore.component/trunk/src/grok/tests/view/inline.py
D grokcore.component/trunk/src/grok/tests/view/inline_unassociated.py
D grokcore.component/trunk/src/grok/tests/view/inlinebogus.py
D grokcore.component/trunk/src/grok/tests/view/missingcontext.py
D grokcore.component/trunk/src/grok/tests/view/namemultiple.py
D grokcore.component/trunk/src/grok/tests/view/namemultiple_fixture.py
D grokcore.component/trunk/src/grok/tests/view/nameunicode.py
D grokcore.component/trunk/src/grok/tests/view/notemplateorrender.py
D grokcore.component/trunk/src/grok/tests/view/template.py
D grokcore.component/trunk/src/grok/tests/view/templatedirectory.py
D grokcore.component/trunk/src/grok/tests/view/templatedirectoryname/
D grokcore.component/trunk/src/grok/tests/view/templatefile.py
D grokcore.component/trunk/src/grok/tests/view/templatenotfound.py
D grokcore.component/trunk/src/grok/tests/view/templatereload.py
D grokcore.component/trunk/src/grok/tests/view/templatereload_templates/
D grokcore.component/trunk/src/grok/tests/view/twoviewsusetemplate.py
D grokcore.component/trunk/src/grok/tests/view/unassociated.py
D grokcore.component/trunk/src/grok/tests/view/unassociated_templates/
D grokcore.component/trunk/src/grok/tests/view/update.py
D grokcore.component/trunk/src/grok/tests/view/update_redirect.py
D grokcore.component/trunk/src/grok/tests/view/view.py
D grokcore.component/trunk/src/grok/tests/viewlet/
D grokcore.component/trunk/src/grok/tests/xmlrpc/
D grokcore.component/trunk/src/grok/tests/zcml/
-=-
Deleted: grokcore.component/trunk/src/grok/tests/utility/local_implementsmany.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/local_implementsmany.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/local_implementsmany.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,30 +0,0 @@
-"""
-Anything can be registered as a local utility. If it implements a single
-interface, there is no need to specify which interface it provides.
-
-In this test, the utility implements more than one interface, so it cannot be
-registered as a local utility.
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: <class 'grok.tests.utility.local_implementsmany.Fireplace'>
- is implementing more than one interface (use grok.provides to specify
- which one to use).
-
-"""
-
-import grok
-from zope import interface
-
-class IHome(interface.Interface):
- pass
-
-class IFireplace(interface.Interface):
- pass
-
-class Fireplace(object):
- interface.implements(IHome, IFireplace)
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace)
Deleted: grokcore.component/trunk/src/grok/tests/utility/local_implementsnone.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/local_implementsnone.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/local_implementsnone.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,23 +0,0 @@
-"""
-Anything can be registered as a local utility. If it implements a single
-interface, there is no need to specify which interface it provides.
-
-In this test, the utility does not implement any interface, so it cannot be
-registered as a local utility.
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: <class 'grok.tests.utility.local_implementsnone.Fireplace'>
- must implement at least one interface (use grok.implements to specify).
-
-"""
-
-import grok
-from zope import interface
-
-class Fireplace(object):
- pass
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace)
Deleted: grokcore.component/trunk/src/grok/tests/utility/local_implementsnone2.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/local_implementsnone2.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/local_implementsnone2.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,25 +0,0 @@
-"""
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: Cannot determine which interface to use for utility registration of
- <class 'grok.tests.utility.local_implementsnone2.Fireplace'> in site
- <class 'grok.tests.utility.local_implementsnone2.Cave'>. It implements
- an interface that is a specialization of an interface implemented
- by grok.LocalUtility. Specify the interface by either using grok.provides on
- the utility or passing 'provides' to grok.local_utility.
-
-"""
-
-import grok
-from zope import interface
-import persistent
-
-class ISpecialPersistent(persistent.interfaces.IPersistent):
- pass
-
-class Fireplace(grok.LocalUtility):
- grok.implements(ISpecialPersistent)
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace)
Deleted: grokcore.component/trunk/src/grok/tests/utility/multiple_class.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/multiple_class.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/multiple_class.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,29 +0,0 @@
-"""
-When you try to register multiple classes with the same (interface, name)
-combination multiple times using grok.local_utility, we expect an error:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: Conflicting local utility registration
- <class 'grok.tests.utility.multiple_class.Fireplace2'> in site
- <class 'grok.tests.utility.multiple_class.Cave'>.
- Local utilities are registered multiple times for interface
- <InterfaceClass grok.tests.utility.multiple_class.IFireplace> and
- name 'Foo'.
-"""
-import grok
-from zope import interface
-
-class IFireplace(interface.Interface):
- pass
-
-class Fireplace(grok.LocalUtility):
- grok.implements(IFireplace)
-
-class Fireplace2(grok.LocalUtility):
- grok.implements(IFireplace)
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace, name='Foo')
- grok.local_utility(Fireplace2, name='Foo')
Deleted: grokcore.component/trunk/src/grok/tests/utility/multiple_directive.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/multiple_directive.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/multiple_directive.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,29 +0,0 @@
-"""
-When you call the grok.local_utility directive multiple times specifying
-the same (interface, name) combination, we expect an error:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: Conflicting local utility registration
- <class 'grok.tests.utility.multiple_directive.Fireplace2'> in site
- <class 'grok.tests.utility.multiple_directive.Cave'>.
- Local utilities are registered multiple times for interface
- <InterfaceClass grok.tests.utility.multiple_directive.IFireplace> and
- name u''.
-"""
-import grok
-from zope import interface
-
-class IFireplace(interface.Interface):
- pass
-
-class Fireplace(grok.LocalUtility):
- grok.implements(IFireplace)
-
-class Fireplace2(grok.LocalUtility):
- grok.implements(IFireplace)
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace, provides=IFireplace)
- grok.local_utility(Fireplace2, provides=IFireplace)
Deleted: grokcore.component/trunk/src/grok/tests/utility/publicnoncontainer.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/utility/publicnoncontainer.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/utility/publicnoncontainer.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,23 +0,0 @@
-"""
-You cannot use local_utility with 'public' set to True if the site class
-isn't a container:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: Cannot set public to True with grok.local_utility as the site
- (<class 'grok.tests.utility.publicnoncontainer.Cave'>) is not a container.
-
-"""
-
-import grok
-from zope import interface
-
-class IFireplace(interface.Interface):
- pass
-
-class Fireplace(grok.LocalUtility):
- grok.implements(IFireplace)
-
-class Cave(grok.Model, grok.Site):
- grok.local_utility(Fireplace, public=True, name_in_container='fireplace')
Deleted: grokcore.component/trunk/src/grok/tests/view/ambiguouscontext.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/ambiguouscontext.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/ambiguouscontext.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,21 +0,0 @@
-"""
-Templates with ambiguous context cannot be grokked:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: Multiple possible contexts for
- <class 'grok.tests.view.ambiguouscontext.Club'>, please use grok.context.
-
-"""
-
-import grok
-
-class Cave(grok.Model):
- pass
-
-class Mammoth(grok.Model):
- pass
-
-class Club(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/dirandinlinetemplate.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/dirandinlinetemplate.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/dirandinlinetemplate.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,20 +0,0 @@
-"""
-If multiple templates can be found, one in the module and one in the
-template directory, there is an error:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: Conflicting templates found for name 'cavepainting' in module
- <module 'grok.tests.view.dirandinlinetemplate' from ...
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- pass
-
-cavepainting = grok.PageTemplate("nothing")
Deleted: grokcore.component/trunk/src/grok/tests/view/dirtemplate.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/dirtemplate.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/dirtemplate.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,36 +0,0 @@
-"""
-Templates can also be found in a directory with the same name as the module:
-
- >>> grok.testing.grok(__name__)
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='cavepainting')
- >>> print view()
- <html>
- <body>
- A cave painting.
- </body>
- </html>
-
- >>> view = component.getMultiAdapter((manfred, request), name='food')
- >>> print view()
- <html>
- <body>
- ME GROK EAT MAMMOTH!
- </body>
- </html>
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- pass
-
-class Food(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/dirtemplateandrender.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/dirtemplateandrender.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/dirtemplateandrender.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,21 +0,0 @@
-"""
-A View may either have an associated template or a render-method. Here
-we check that this also works for templates in a template-directory:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: Multiple possible ways to render view
- <class 'grok.tests.view.dirtemplateandrender.CavePainting'>.
- It has both a 'render' method as well as an associated template.
- in:
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- def render(self):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/dirtemplatesonly.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/dirtemplatesonly.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/dirtemplatesonly.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,23 +0,0 @@
-"""
-A template directory may only contain recognized template files::
-
- >>> from zope.deprecation.tests import warn
- >>> import warnings
- >>> saved_warn = warnings.warn
- >>> warnings.warn = warn
-
- >>> grok.testing.grok(__name__)
- From tests.py's showwarning():
- ... UserWarning: File 'invalid.txt' has an unrecognized extension in
- directory '...dirtemplatesonly_templates'...
-
- >>> warnings.warn = saved_warn
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class Index(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/eithertemplateorrender.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/eithertemplateorrender.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/eithertemplateorrender.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,21 +0,0 @@
-"""
-Only one, either a template, or render() can be specified:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: Multiple possible ways to render view
- <class 'grok.tests.view.eithertemplateorrender.CavePainting'>.
- It has both a 'render' method as well as an associated template.
- in:
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- def render(self):
- pass
-
-cavepainting = grok.PageTemplate("nothing")
Deleted: grokcore.component/trunk/src/grok/tests/view/explicitimplicittemplate.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/explicitimplicittemplate.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/explicitimplicittemplate.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,25 +0,0 @@
-"""
-It is too confusing to have a template that would be implicitly
-associated with a view while that view already refers to another
-template using grok.template. Therefore there is an error:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: Multiple possible templates for view
- <class 'grok.tests.view.explicitimplicittemplate.Painting'>.
- It uses grok.template('cavepainting'), but there is also a template
- called 'painting'.
- in:
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class Painting(grok.View):
- grok.template('cavepainting')
-
-cavepainting = grok.PageTemplate("GROK CAVEPAINT MAMMOTH!")
-painting = grok.PageTemplate("GROK PAINT MAMMOTH!")
Deleted: grokcore.component/trunk/src/grok/tests/view/inline.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/inline.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/inline.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,65 +0,0 @@
-"""
-Templates can be specified in the same module as the view,
-using a variable named `viewname_pt`:
-
- >>> grok.testing.grok(__name__)
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='cavepainting')
- >>> print view()
- <html>
- <body>
- <h1>Mammoth Cave Painting</h1>
- <ul>
- <li><zope.publisher.browser.TestRequest instance URL=http://127.0.0.1></li>
- <li><grok.tests.view.inline.CavePainting object at 0x...></li>
- <li><grok.tests.view.inline.Mammoth object at 0x...></li>
- <li><zope.app.pagetemplate.engine.TraversableModuleImporter object at 0x...></li>
- </ul>
- </body>
- </html>
-
-Note that the CavePainting instance is bound to the ``view`` name in
-the template. This shows that the association of inline PageTemplate
-and the view class is successful.
-
-Finding a template does not depend on the view name, but on the class
-name:
-
- >>> view = component.getMultiAdapter((manfred, request), name='hunting')
- >>> print view()
- <html><body><h1>GROK HUNT MAMMOTH!</h1></body></html>
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- pass
-
-cavepainting = grok.PageTemplate("""\
-<html>
-<body>
-<h1 tal:content="string:Mammoth Cave Painting"/>
-<ul>
- <li tal:content="structure python:repr(request)" />
- <li tal:content="structure nocall:view" />
- <li tal:content="structure nocall:context" />
- <li tal:content="structure nocall:modules" />
-</ul>
-</body>
-</html>
-""")
-
-class Hunt(grok.View):
- grok.name('hunting')
-
-hunt = grok.PageTemplate("""\
-<html><body><h1>GROK HUNT MAMMOTH!</h1></body></html>
-""")
-
Deleted: grokcore.component/trunk/src/grok/tests/view/inline_unassociated.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/inline_unassociated.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/inline_unassociated.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,26 +0,0 @@
-"""
-Inline templates that are not associated with a view class will
-provoke an error:
-
- >>> from zope.deprecation.tests import warn
- >>> import warnings
- >>> saved_warn = warnings.warn
- >>> warnings.warn = warn
-
- >>> grok.testing.grok(__name__)
- From tests.py's showwarning():
- ...UserWarning: Found the following unassociated template(s) when grokking
- 'grok.tests.view.inline_unassociated': club. Define view classes inheriting
- from grok.View to enable the template(s).
-
- >>> warnings.warn = saved_warn
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-club = grok.PageTemplate("""\
-<html><body><h1>GROK CLUB MAMMOTH!</h1></body></html>
-""")
Deleted: grokcore.component/trunk/src/grok/tests/view/inlinebogus.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/inlinebogus.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/inlinebogus.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,16 +0,0 @@
-# -*- coding: latin-1 -*-
-"""
-We do not accept bogus inline template such as ones that contain
-encoded strings:
-
- >>> import grok
- >>> grok.PageTemplate('''
- ... <html>
- ... <body><h1 tal:content="string:Mammoth Cave Painting"/>
- ... <p>ööö</p>
- ... </body>
- ... </html>''')
- Traceback (most recent call last):
- ...
- ValueError: Invalid page template. Page templates must be unicode or ASCII.
-"""
Deleted: grokcore.component/trunk/src/grok/tests/view/missingcontext.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/missingcontext.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/missingcontext.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,15 +0,0 @@
-"""
-Views without a context cannot be grokked:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- GrokError: No module-level context for
- <class 'grok.tests.view.missingcontext.Club'>, please use grok.context.
-
-"""
-
-import grok
-
-class Club(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/namemultiple.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/namemultiple.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/namemultiple.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,9 +0,0 @@
-"""
-You can't call grok.name multiple times for a view
-
- >>> import grok.tests.view.namemultiple_fixture
- Traceback (most recent call last):
- ...
- GrokImportError: grok.name can only be called once per class.
-
-"""
Deleted: grokcore.component/trunk/src/grok/tests/view/namemultiple_fixture.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/namemultiple_fixture.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/namemultiple_fixture.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,8 +0,0 @@
-"""
-This should fail:
-"""
-import grok
-
-class MultipleNames(grok.View):
- grok.name('mammoth')
- grok.name('bear')
Deleted: grokcore.component/trunk/src/grok/tests/view/nameunicode.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/nameunicode.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/nameunicode.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,28 +0,0 @@
-# -*- coding: latin-1 -*-
-"""
-You can only pass unicode to `grok.name`:
-
- >>> pass_unicode()
- >>> pass_encodedstring()
- Traceback (most recent call last):
- ...
- GrokImportError: You can only pass unicode or ASCII to grok.name.
- >>> pass_object()
- Traceback (most recent call last):
- ...
- GrokImportError: You can only pass unicode or ASCII to grok.name.
-
-"""
-import grok
-
-def pass_unicode():
- class View(object):
- grok.name(u'name')
-
-def pass_encodedstring():
- class View(object):
- grok.name("ölkj")
-
-def pass_object():
- class View(object):
- grok.name(object())
Deleted: grokcore.component/trunk/src/grok/tests/view/notemplateorrender.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/notemplateorrender.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/notemplateorrender.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,19 +0,0 @@
-"""
-Views either need an associated template or a ``render`` method:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: View <class 'grok.tests.view.notemplateorrender.CavePainting'>
- has no associated template or 'render' method.
- in:
-
-"""
-
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/template.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/template.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/template.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,41 +0,0 @@
-"""
-
- >>> grok.testing.grok(__name__)
-
-View with an associated PageTemplate that is referred to using
-``grok.template``:
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='painting')
- >>> print view()
- <html><body><h1>GROK PAINT MAMMOTH!</h1></body></html>
-
-``grok.name`` and ``grok.template`` can be combined:
-
- >>> view = component.getMultiAdapter((manfred, request), name='meal')
- >>> print view()
- <html><body><h1>GROK EAT MAMMOTH!</h1></body></html>
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class Painting(grok.View):
- grok.template('cavepainting')
-
-cavepainting = grok.PageTemplate("""\
-<html><body><h1>GROK PAINT MAMMOTH!</h1></body></html>
-""")
-
-class Food(grok.View):
- grok.template('food_template')
- grok.name('meal')
-
-food_template = grok.PageTemplate("""\
-<html><body><h1>GROK EAT MAMMOTH!</h1></body></html>
-""")
Deleted: grokcore.component/trunk/src/grok/tests/view/templatedirectory.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/templatedirectory.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/templatedirectory.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,27 +0,0 @@
-"""
-You can explicitly specify the template directory using grok.templatedir on module level:
-
- >>> grok.testing.grok(__name__)
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='food')
- >>> print view()
- <html>
- <body>
- ME GROK EAT MAMMOTH!
- </body>
- </html>
-
-"""
-import grok
-
-grok.templatedir('templatedirectoryname')
-
-class Mammoth(grok.Model):
- pass
-
-class Food(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/templatefile.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/templatefile.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/templatefile.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,31 +0,0 @@
-"""
-
- >>> grok.testing.grok(__name__)
-
-View with an associated PageTemplate that is referred to using
-``grok.template``:
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='food')
- >>> print view()
- <html>
- <body>
- ME GROK EAT MAMMOTH!
- </body>
- </html>
-
-"""
-import grok
-import os.path
-
-class Mammoth(grok.Model):
- pass
-
-class Food(grok.View):
- pass
-
-food = grok.PageTemplate(filename=os.path.join('templatedirectoryname',
- 'food.pt'))
Deleted: grokcore.component/trunk/src/grok/tests/view/templatenotfound.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/templatenotfound.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/templatenotfound.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,20 +0,0 @@
-"""
-This should fail because ``grok.template`` points to a non-existing
-template:
-
- >>> grok.testing.grok(__name__)
- Traceback (most recent call last):
- ...
- ConfigurationExecutionError: martian.error.GrokError: View <class 'grok.tests.view.templatenotfound.Painting'>
- has no associated template or 'render' method.
- in:
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class Painting(grok.View):
- grok.template('cavepainting')
-
-# no cavepainting template here
Deleted: grokcore.component/trunk/src/grok/tests/view/templatereload.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/templatereload.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/templatereload.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,39 +0,0 @@
-"""
-Filesystem-based templates, once grokked, can be changed. The change
-will automatically be picked up, reloading Zope is not necessary.
-
- >>> grok.testing.grok(__name__)
- >>> from zope.component import getMultiAdapter
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> view = getMultiAdapter((Mammoth(), request), name='index')
- >>> print view()
- before
-
-Now we change the file:
-
- >>> import os.path
- >>> here = os.path.dirname(__file__)
- >>> template_file = os.path.join(here, 'templatereload_templates', 'index.pt')
- >>> template = open(template_file, 'w')
- >>> template.write('after')
- >>> template.close()
-
-and find that the output of the view has changed as well:
-
- >>> print view()
- after
-
-At last, we should change everything back to normal:
-
- >>> template = open(template_file, 'w')
- >>> template.write('before')
- >>> template.close()
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class Index(grok.View):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/twoviewsusetemplate.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/twoviewsusetemplate.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/twoviewsusetemplate.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,61 +0,0 @@
-"""
-A template can be used by multiple views at the same time:
-
- >>> grok.testing.grok(__name__)
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
-
- >>> view = component.getMultiAdapter((manfred, request), name='a')
- >>> print view()
- View A
-
- >>> view = component.getMultiAdapter((manfred, request), name='b')
- >>> print view()
- View A
-
-It also works if templates are both associated explicitly:
-
- >>> view = component.getMultiAdapter((manfred, request), name='c')
- >>> print view()
- Template
-
- >>> view = component.getMultiAdapter((manfred, request), name='d')
- >>> print view()
- Template
-
-Because the template is associated, we do not expect it to be
-registered as its own view:
-
- >>> view = component.getMultiAdapter((manfred, request), name='templ')
- Traceback (most recent call last):
- ...
- ComponentLookupError:
- ((<grok.tests.view.twoviewsusetemplate.Mammoth object at 0x...>,
- <zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
- <InterfaceClass zope.interface.Interface>, 'templ')
-
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class A(grok.View):
- pass
-
-a = grok.PageTemplate("View A")
-
-class B(grok.View):
- grok.template('a')
-
-class C(grok.View):
- grok.template('templ')
-
-class D(grok.View):
- grok.template('templ')
-
-templ = grok.PageTemplate('Template')
Deleted: grokcore.component/trunk/src/grok/tests/view/unassociated.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/unassociated.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/unassociated.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,22 +0,0 @@
-"""
-Templates that are not associated with a view class will provoke an
-error:
-
- >>> from zope.deprecation.tests import warn
- >>> import warnings
- >>> saved_warn = warnings.warn
- >>> warnings.warn = warn
-
- >>> grok.testing.grok(__name__)
- From tests.py's showwarning():
- ...UserWarning: Found the following unassociated template(s) when grokking
- 'grok.tests.view.unassociated': index. Define view classes inheriting from
- grok.View to enable the template(s).
-
- >>> warnings.warn = saved_warn
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
Deleted: grokcore.component/trunk/src/grok/tests/view/update.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/update.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/update.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,46 +0,0 @@
-"""
-Before a view is rendered, the update() method is executed. It can be
-used e. g. to execute side effects or set up data for use in the
-template.
-
- >>> grok.testing.grok(__name__)
-
-We need to set up a default ITraversable adapter so that TALES
-expressions can resolve paths:
-
- >>> from zope import component
- >>> from zope.traversing.adapters import DefaultTraversable
- >>> component.provideAdapter(DefaultTraversable, (None,))
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> view = component.getMultiAdapter((manfred, request), name='cavepainting')
- >>> print view()
- <html>
- <body>
- <h1>red</h1>
- <h1>red</h1>
- </body>
- </html>
-
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- def update(self):
- self.color = "red"
-
-
-cavepainting = grok.PageTemplate("""\
-<html>
-<body>
-<h1 tal:content="view/color"/>
-<h1 tal:content="python: view.color"/>
-</body>
-</html>
-""")
Deleted: grokcore.component/trunk/src/grok/tests/view/update_redirect.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/update_redirect.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/update_redirect.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,36 +0,0 @@
-"""
-When a view's update() method redirects somewhere else, the template
-is not executed subsequently.
-
- >>> grok.testing.grok(__name__)
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope.component import getMultiAdapter
- >>> view = getMultiAdapter((manfred, request), name='cavepainting')
- >>> print view()
- None
- >>> print request.response.getStatus()
- 302
- >>> print request.response.getHeader('Location')
- somewhere-else
-
-"""
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
- def update(self):
- self.request.response.redirect('somewhere-else')
-
-
-cavepainting = grok.PageTemplate("""\
-<html>
-<body>
-<h1 tal:content="this-is-an-error" />
-</body>
-</html>
-""")
Deleted: grokcore.component/trunk/src/grok/tests/view/view.py
===================================================================
--- grokcore.component/trunk/src/grok/tests/view/view.py 2008-03-17 19:27:42 UTC (rev 84744)
+++ grokcore.component/trunk/src/grok/tests/view/view.py 2008-03-17 20:24:12 UTC (rev 84745)
@@ -1,50 +0,0 @@
-"""
-
- >>> grok.testing.grok(__name__)
-
-We should find the ``cavepainting`` view for a mammoth:
-
- >>> manfred = Mammoth()
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> from zope import component
- >>> view = component.getMultiAdapter((manfred, request), name='cavepainting')
- >>> view()
- 'A cave painting of a mammoth'
-
- >>> view.context is manfred
- True
- >>> view.request is request
- True
-
-Look up a view with a name explicitly set with ``grok.name``:
-
- >>> view = component.getMultiAdapter((manfred, request), name='meal')
- >>> view()
- 'Mammoth burger'
-
-There's no view 'food':
-
- >>> view = component.getMultiAdapter((manfred, request), name='food')
- Traceback (most recent call last):
- ...
- ComponentLookupError: ((<grok.tests.view.view.Mammoth object at 0x...>, <zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), <InterfaceClass zope.interface.Interface>, 'food')
-
-"""
-
-import grok
-
-class Mammoth(grok.Model):
- pass
-
-class CavePainting(grok.View):
-
- def render(self):
- return 'A cave painting of a mammoth'
-
-class Food(grok.View):
- """Grok says: ME NO SEE MAMMOTH, ME SEE MEAL!"""
- grok.name('meal')
-
- def render(self):
- return 'Mammoth burger'
More information about the Checkins
mailing list