Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Update tests in the resulting package to use the fanstatic layer. Fix…
Browse files Browse the repository at this point in the history
… tests.
  • Loading branch information
janjaapdriessen committed Dec 3, 2010
1 parent 9ad3789 commit cfbd80b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
2 changes: 2 additions & 0 deletions grokproject/template/buildout.cfg_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ fanstatic = hg http://bitbucket.org/fanstatic/fanstatic
zope.fanstatic = svn http://svn.zope.org/repos/main/zope.fanstatic/trunk

[versions]
WebOb = 1.0
zope.app.wsgi = 3.10.0
# Override versions here.

# Once groktoolkit 1.2 is released, remove this line:
Expand Down
2 changes: 1 addition & 1 deletion grokproject/template/setup.py_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ ${long_description|nothing}""",
],
entry_points={
'fanstatic.libraries': [
'foo = ${project}.resource:library',
'foo = ${project_lowercase}.resource:library',
]
})
5 changes: 5 additions & 0 deletions grokproject/template/src/+package+/app.txt_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Check some basic information about the page you visit:
>>> print browser.contents
<html>
<head>
<link rel="stylesheet" type="text/css"
href="http://localhost/fanstatic/foo/style.css" />
<script type="text/javascript"
src="http://localhost/fanstatic/foo/hello.js"></script>
<base href="http://localhost/app/@@index" />
<BLANKLINE>
</head>
Expand All @@ -41,6 +45,7 @@ Check some basic information about the page you visit:
<p>Your Grok application is up and running.
Edit <code>${package}/app_templates/index.pt</code> to change
this page.</p>
<img src="http://localhost/fanstatic/foo/evencaveman.jpg" />
</body>
</html>
<BLANKLINE>
7 changes: 6 additions & 1 deletion grokproject/template/src/+package+/tests.py_tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os.path
import z3c.testsetup
from zope.app.wsgi.testlayer import BrowserLayer
import fanstatic

import ${package}

browser_layer = BrowserLayer(${package})
class FanstaticLayer(BrowserLayer):
def setup_middleware(self, app):
return fanstatic.Fanstatic(app)

browser_layer = FanstaticLayer(${package})

test_suite = z3c.testsetup.register_all_tests(
'${package}', globs={'getRootFolder': browser_layer.getRootFolder})
1 change: 1 addition & 0 deletions grokproject/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def check_vars(self, vars, cmd):
# Escape values that go in site.zcml.
vars[var_name] = xml.sax.saxutils.quoteattr(vars[var_name])
vars['app_class_name'] = vars['project'].capitalize()
vars['project_lowercase'] = vars['project'].lower()

# Handling the version.cfg file.
version_url = vars.get('version_url')
Expand Down
53 changes: 28 additions & 25 deletions tests_paste.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ Then use paster. Eggs are placed in our freshly created eggs directory:
Generated interpreter '...python-console'.
Installing daemon.
Generated script '...daemon'.
Installing debug_ini.
Installing deploy_ini.
Installing site_zcml.
Installing zope_conf_debug.
...
Installing paster_ini_debug.
Installing zope_conf_deploy.
...
Installing paster_ini_deploy.
Installing i18n.
i18n: setting up i18n tools
Generated script '...i18nextract'.
Generated script '...i18nmergeall'.
Generated script '...i18nstats'.
Generated script '...i18ncompile'.
Installing site_zcml.
Installing zope_conf.
Installing mkdirs.
mkdirs: created path: ...var
mkdirs: created path: ...filestorage
Expand Down Expand Up @@ -71,13 +74,13 @@ Let's check the contents:
[buildout]
extends = http://grok.zope.org/releaseinfo/1.2b/versions.cfg
extends-cache = extends-cache
find-links =
include-site-packages = false
develop = .
...

>>> ls(package_dir)
.installed.cfg
.mr.developer.cfg
bin
bootstrap.py
buildout.cfg
Expand All @@ -96,15 +99,18 @@ Let's check the contents:
app.py
app.txt
app_templates
browser
configure.zcml
ftesting.zcml
resource.py
static
tests.py

>>> bin_dir = os.path.join(package_dir, 'bin')
>>> ls(bin_dir)
buildout
daemon
develop
i18ncompile
i18nextract
i18nmergeall
Expand All @@ -120,11 +126,14 @@ Let's check the contents:
debug.ini
deploy.ini
site.zcml
zope.conf
zope.debug.conf
zope.deploy.conf

In the generated configuration files paths are set to local paths:
In the generated configuration files paths are set to local paths.
We used a projectname with uppercase letters. This is respected by
configuration files:

>>> cat(etc_dir, 'zope.conf')
>>> cat(etc_dir, 'zope.debug.conf')
# Identify the component configuration used to define the site:
site-definition /.../GrokExample/parts/etc/site.zcml
...
Expand All @@ -143,15 +152,6 @@ cached versions file for 1.2b will look like:
1cd99c06b44977edcb9281133f31007b
f74256c0d403a6bb45c38b9ce42c783c

We used a projectname with uppercase letters. This is respected by
configuration files:

>>> zope_conf = os.path.join(package_dir, 'parts', 'etc', 'zope.conf')
>>> print open(zope_conf, 'rb').read()
# Identify the component configuration used to define the site:
site-definition ...GrokExample/parts/etc/site.zcml
...

The password given is stored SSHA encoded:

>>> site_zcml_in = os.path.join(package_dir, 'etc',
Expand Down Expand Up @@ -266,13 +266,13 @@ We can run tests:
>>> print 'Test:\n' + output
Test...
Running tests at level 1
Running grokexample.BrowserLayer tests:
Set up grokexample.BrowserLayer in ... seconds.
Running grokexample.FanstaticLayer tests:
Set up grokexample.FanstaticLayer in ... seconds.
Running:
...
Ran 3 tests with 0 failures and 0 errors in ... seconds.
Tearing down left over layers:
Tear down grokexample.BrowserLayer in ... seconds.
Tear down grokexample.FanstaticLayer in ... seconds.
<BLANKLINE>

Using the generated `buildout` script
Expand All @@ -285,16 +285,19 @@ first:
>>> cd(package_dir)
>>> cmd = os.path.join(bin_dir, 'buildout')
>>> output = read_sh(cmd)
>>> print output
>>> print 'Test\n', output
Test
...
Develop: ...
Updating app.
Updating daemon.
Updating debug_ini.
Updating deploy_ini.
Updating site_zcml.
Updating zope_conf_debug.
Updating paster_ini_debug.
Updating zope_conf_deploy.
Updating paster_ini_deploy.
Updating i18n.
i18n: setting up i18n tools
Updating site_zcml.
Updating zope_conf.
Updating mkdirs.
Updating test.
Updating zpasswd.
Expand Down

0 comments on commit cfbd80b

Please sign in to comment.