[Checkins] SVN: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/ Moving all tests to README.txt, to avoid repeating ourselves.
Souheil CHELFOUH
souheil at chelfouh.com
Sat Dec 19 13:28:56 EST 2009
Log message for revision 106785:
Moving all tests to README.txt, to avoid repeating ourselves.
It's not like we have much to test...
Changed:
U Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/__init__.py
A Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/ftesting.zcml
D Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/templates/
D Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_mf.py
-=-
Modified: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/__init__.py
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/__init__.py 2009-12-19 18:13:07 UTC (rev 106784)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/__init__.py 2009-12-19 18:28:56 UTC (rev 106785)
@@ -1,9 +1,9 @@
+# -*- coding: utf-8 -*-
+
import os.path
import megrok.resource
-
from zope.app.testing.functional import ZCMLLayer
-ftesting_zcml = os.path.join(os.path.dirname(megrok.resource.__file__),
- 'ftesting.zcml')
-FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'FunctionalLayer',
- allow_teardown=True)
+ftesting_zcml = os.path.join(os.path.dirname(__file__), 'ftesting.zcml')
+FunctionalLayer = ZCMLLayer(
+ ftesting_zcml, __name__, 'FunctionalLayer', allow_teardown=True)
Copied: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/ftesting.zcml (from rev 106777, Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftesting.zcml)
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/ftesting.zcml (rev 0)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/ftesting.zcml 2009-12-19 18:28:56 UTC (rev 106785)
@@ -0,0 +1,44 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:grok="http://namespaces.zope.org/grok"
+ i18n_domain="zope"
+ >
+
+ <include package="zope.app.zcmlfiles" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
+
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+
+ <!-- Load minimal support of grokcore.view, views + templates -->
+ <include package="grokcore.view" file="meta.zcml" />
+ <include package="grokcore.view" />
+
+ <include package="megrok.resource" />
+ <grok:grok package="megrok.resource.ftests" />
+
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+ />
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User"
+ />
+ <grant
+ permission="zope.View"
+ principal="zope.anybody"
+ />
+
+ <principal
+ id="zope.mgr"
+ title="Manager"
+ login="mgr"
+ password="mgrpw"
+ />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager" principal="zope.mgr" />
+
+</configure>
Deleted: Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_mf.py
===================================================================
--- Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_mf.py 2009-12-19 18:13:07 UTC (rev 106784)
+++ Sandbox/cklinger/megrok.resource/trunk/src/megrok/resource/ftests/test_mf.py 2009-12-19 18:28:56 UTC (rev 106785)
@@ -1,109 +0,0 @@
-"""
-megrok.resource
-===============
-
-
-Setup
------
-
- >>> from zope.app.testing.functional import getRootFolder
- >>> from zope.app.container import btree
- >>> from zope.app.component.site import LocalSiteManager
- >>> from zope.app.component.hooks import setSite
-
- >>> root = getRootFolder()
- >>> root['simpleapp'] = Application()
-
-Our application has to be a Site to access the right url for the inclusions
-
- >>> root['simpleapp'].setSiteManager(LocalSiteManager(root['simpleapp']))
- >>> setSite(root['simpleapp'])
- >>> root['simpleapp']
- <megrok.resource.ftests.test_mf.Application object at ...>
-
-
-ResourceDirectory
------------------
-
-If we create a Library we should get an fully registerd ResourceDirectory.
-
- >>> from zope.testbrowser.testing import Browser
- >>> browser = Browser()
- >>> browser.handleErrors = False
- >>> browser.open('http://localhost/@@/mylibrary/a.js')
- >>> print browser.contents
- /* Simple JS */
-
-For default we can access these resources with the help of z3c.hashedresource
-First we have to get the hash to look for the resource in the testbrowser.
-
- >>> from zope.component import getAdapter
- >>> from zope.publisher.browser import TestRequest
- >>> library = getAdapter(TestRequest(), name='mylibrary')
- >>> library
- <grokcore.view.components.DirectoryResource object at ...>
-
- >>> from z3c.hashedresource.interfaces import IResourceContentsHash
- >>> hash = IResourceContentsHash(library)
-
- >>> ajs = 'http://localhost/@@/++noop++%s/mylibrary/a.js' % hash
- >>> browser.open(ajs)
- >>> print browser.contents
- /* Simple JS */
-
- >>> browser.open('http://localhost/simpleapp/simpleview')
- >>> stag%(hash) in browser.contents
- True
-
- >>> print browser.contents
- <html>
- <head>
- ...
- </head>
- <body>
- <h1> HI GROK </h1>
- </body>
- </html>
-
-
-"""
-
-stag = '<script type="text/javascript" src="http://localhost/simpleapp/@@/++noop++%s/mylibrary/a.js"></script>'
-
-import grokcore.component as grok
-import grokcore.view as view
-
-from megrok import resource
-from zope.interface import Interface
-from zope.app.component.site import SiteManagerContainer
-from hurry.resource import ResourceInclusion
-
-class Application(SiteManagerContainer):
- """ Sample Application """
-
-
-class MyLibrary(resource.Library):
- resource.path('css')
- resource.name('mylibrary')
-
-myjs = ResourceInclusion(MyLibrary, 'a.js')
-
-
-class SimpleView(view.View):
- grok.context(Interface)
- resource.need(myjs)
- resource.use_hash(False)
-
- template = view.PageTemplateFile('templates/myview.pt')
-
-
-###TestSetup
-def test_suite():
- from zope.testing import doctest
- from megrok.resource.ftests import FunctionalLayer
- suite = doctest.DocTestSuite(
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
- )
- suite.layer = FunctionalLayer
- return suite
-
More information about the checkins
mailing list