Skip to content

Commit

Permalink
Add html-wrap helper and update buildout/travis
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Apr 26, 2018
1 parent 7bbb7c9 commit 414c43e
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 271 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ cache:
directories:
- eggs
python:
- 2.7
- 2.7.13
env:
- PLONE_VERSION=5.0
- PLONE_VERSION=5.1
before_install:
- pip install --upgrade pip setuptools==20.7.0 zc.buildout
- pip install -r https://raw.githubusercontent.com/plone/buildout.coredev/5.1/requirements.txt
install:
- sed -ie "s#test-5.1#test-$PLONE_VERSION#" buildout.cfg
- buildout annotate
- buildout
script:
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.3 (unreleased)
----------------

- Nothing changed yet.
- Set html/body parenthesis for tiles
[tomgross]


1.2 (2016-10-31)
Expand Down
189 changes: 0 additions & 189 deletions bootstrap-buildout.py

This file was deleted.

75 changes: 11 additions & 64 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
[buildout]
extends = http://dist.plone.org/release/5.0.6/versions.cfg
extensions = mr.developer
parts =
instance
test
code-analysis
releaser
i18ndude
omelette
robot
coverage
develop = .
extends = https://raw.github.com/collective/buildout.plonetest/master/test-5.1.x.cfg
package-name = collective.handlebars
package-extras = [test]
parts +=
coverage
code-analysis


[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
[coverage]
recipe = zc.recipe.egg
eggs =
Plone
Pillow
collective.handlebars [test]
${test:eggs}
coverage
python-coveralls


[code-analysis]
Expand All @@ -34,58 +26,13 @@ flake8-extensions =
flake8-coding


[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}


[test]
recipe = zc.recipe.testrunner
eggs = ${instance:eggs}
defaults = ['-s', 'collective.handlebars', '--auto-color', '--auto-progress']


[robot]
recipe = zc.recipe.egg
eggs =
${test:eggs}
plone.app.robotframework[debug,ride,reload]


[releaser]
recipe = zc.recipe.egg
eggs = zest.releaser


[i18ndude]
recipe = zc.recipe.egg
eggs = i18ndude


[coverage]
recipe = zc.recipe.egg
eggs =
${test:eggs}
coverage
python-coveralls


[versions]
# Don't use a released version of collective.handlebars
collective.handlebars =

setuptools = 20.7.0
zc.buildout = 2.5.1
zc.recipe.egg = 2.0.3
flake8 = 3.0.4
flake8_coding = 1.3.0
flake8-debugger = 1.4.0
i18ndude = 4.0.1
robotframework = 3.0
robotframework-ride = 1.5.2.1
robotframework-selenium2library = 1.7.4
robotsuite = 1.7.0
selenium = 2.53.1
plone.testing = 5.0.0
coverage = 4.0.3
python-coveralls = 2.7.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Environment :: Web Environment",
"Framework :: Plone",
"Framework :: Plone :: 5.0",
"Framework :: Plone :: 5.1",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Operating System :: OS Independent",
Expand Down
3 changes: 3 additions & 0 deletions src/collective/handlebars/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def translate(self, msgid, domain=None, mapping=None, context=None,
default=default,
target_language=target_language)

def _wrap_widget(self, render):
return ''.join([u'<html><body>', render, u'</body></html>'])


class HandlebarsBrowserView(BrowserView, HandlebarsMixin):
""" A simple browserview using hbs as templating engine"""
Expand Down
14 changes: 1 addition & 13 deletions src/collective/handlebars/tests/data/minimal_plone.html
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
<section id="content-core">


<div class="entry">
<h1>Fäncy Title</h1>
<div class="body">
This is the Plone View body
</div>
</div>



</section>
<section id="content-core"> <div class="entry"> <h1>Fäncy Title</h1> <div class="body"> This is the Plone View body </div> </div> </section>
1 change: 1 addition & 0 deletions src/collective/handlebars/tests/data/minimal_plone_51.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="content-core"> <div class="entry"> <h1>Fäncy Title</h1> <div class="body"> This is the Plone View body </div> </div> </div>
21 changes: 19 additions & 2 deletions src/collective/handlebars/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
_ = MessageFactory('my.domain')


def normalize(stream):
return ' '.join([snippet.strip() for snippet in stream.split()])


class DummyHbsTile(HandlebarsTile):

def get_contents(self):
Expand Down Expand Up @@ -133,6 +137,12 @@ def test_helpers(self):
result_file = open(os.path.join(TEST_DATA__DIR, 'helper.html'))
self.assertEqual(view(), unicode(result_file.read(), encoding='utf-8'))

def test_render_helper(self):
view = HandlebarsBrowserView(self.portal, self.layer['request'])
rendered = view._wrap_widget('<em>Hello unittest</em>')
self.assertEqual(
rendered, '<html><body><em>Hello unittest</em></body></html>')


class TestPloneView(unittest.TestCase):
"""Test the collective.handlebars BrowserView component."""
Expand Down Expand Up @@ -160,8 +170,15 @@ def test_base_view(self):
def test_example_view(self):
"""Test that a handlebars template is rendered."""
view = self.portal.restrictedTraverse('@@hbs_test_ploneview')
result_file = open(os.path.join(TEST_DATA__DIR, 'minimal_plone.html'))
self.assertIn(unicode(result_file.read(), encoding='utf-8'), view())
if api.env.plone_version().startswith('5.0'):
filename = os.path.join(TEST_DATA__DIR, 'minimal_plone.html')
else:
filename = os.path.join(TEST_DATA__DIR, 'minimal_plone_51.html')
with open(filename) as f:
self.assertIn(
unicode(f.read().strip(), encoding='utf-8'),
normalize(view())
)


class TestUninstall(unittest.TestCase):
Expand Down

0 comments on commit 414c43e

Please sign in to comment.