Skip to content

Commit

Permalink
Fixed tests. Adding configure.zcml to have translations
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Apr 18, 2017
1 parent 6cd3c00 commit bed8d4d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 37 deletions.
14 changes: 6 additions & 8 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ parts = test
find-links = http://pypi.dolmen-project.org/find-links

[test]
recipe = z3c.recipe.scripts
initialization =
import sys
if not sys.argv[1:]: sys.argv.append('src')
sys.argv.append('--doctest-modules')
eggs =
dolmen.breadcrumbs [test]
pytest
recipe = zc.recipe.egg
entry-points = pytest=pytest:main
scripts = pytest
eggs = pytest
dolmen.breadcrumbs[test]
arguments = ['--doctest-modules', '${buildout:directory}/src'] + sys.argv[1:]
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
history = open(join('docs', 'HISTORY.txt')).read()

install_requires = [
'cromlech.i18n',
'cromlech.browser >= 0.5',
'dolmen.location >= 0.2',
'dolmen.template >= 0.2',
Expand Down
2 changes: 2 additions & 0 deletions src/dolmen/breadcrumbs/crumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def resolve_name(item):


def breadcrumbs(item, request, resolver=resolve_name):
if resolver is None:
resolver = resolve_name
kin = lineage_chain(item)
if kin:
kin.reverse()
Expand Down
4 changes: 2 additions & 2 deletions src/dolmen/breadcrumbs/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cromlech.i18n import ILanguage
from dolmen.breadcrumbs import breadcrumbs
from dolmen.template import TALTemplate
from zope.interface import implements
from zope.interface import implementer


TEMPLATES_DIR = path.join(path.dirname(__file__), 'templates')
Expand All @@ -20,8 +20,8 @@ def render_breadcrumbs(renderer, crumbs, separator="→"):
return template.render(renderer, **namespace)


@implementer(IRenderable)
class BreadcrumbsRenderer(object):
implements(IRenderable)

resolver = None

Expand Down
5 changes: 3 additions & 2 deletions src/dolmen/breadcrumbs/templates/breadcrumbs.pt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<a href=""
tal:attributes="href crumb['url']"
tal:content="crumb['name']">name</a>
<span tal:condition="not: repeat['crumb'].end"
class="divider" tal:content="structure separator" />
<span class="divider"
tal:content="structure separator"
tal:condition="not: repeat['crumb'].end" />
</span>
</tal:loop>
</div>
30 changes: 5 additions & 25 deletions src/dolmen/breadcrumbs/test_breadcrumbs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Getting started
===============

>>> from grokcore.component import testing
>>> testing.grok('dolmen.breadcrumbs')
>>> testing.grok('dolmen.location')

We need to provide a root::
Expand Down Expand Up @@ -73,35 +74,14 @@ What if...
KeyError: 'Object name (<...Location object...>) could not be resolved.'


Who art thou ?
==============

>>> from zope.dublincore.interfaces import IDCDescriptiveProperties
>>> from zope.interface import implements

>>> class DescriptiveLocation(Location):
... implements(IDCDescriptiveProperties)
...
... def __init__(self, title="", description="", *args, **kws):
... self.title = title
... self.description = description
... Location.__init__(self, *args, **kws)
Show me !
=========

>>> lady = Location()
>>> locate(lady, root, 'lady')
>>> thane = DescriptiveLocation(title='McBeth')
>>> thane = Location()
>>> locate(thane, lady, 'thane')

>>> print list(breadcrumbs(thane, request))
... # doctest: +NORMALIZE_WHITESPACE
[{'url': 'http://localhost/app', 'name': 'Bob'},
{'url': 'http://localhost/app/lady', 'name': 'lady'},
{'url': 'http://localhost/app/lady/thane', 'name': 'McBeth'}]


Show me !
=========

>>> from dolmen.breadcrumbs import BreadcrumbsRenderer
>>> renderer = BreadcrumbsRenderer(thane, request)
>>> renderer.update()
Expand All @@ -117,6 +97,6 @@ Show me !
<span class="divider">&rarr;</span>
</span>
<span class="crumb">
<a href="http://localhost/app/lady/thane">McBeth</a>
<a href="http://localhost/app/lady/thane">thane</a>
</span>
</div>

0 comments on commit bed8d4d

Please sign in to comment.