diff --git a/CHANGES.rst b/CHANGES.rst index 1b221bb..828c221 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,8 +6,12 @@ Changelog ---------------- - Python 3 / Plone 5.2 compatibility + [adrianschulz, tomgross] + - Update dependencies - Move to Github CI +- Apply black formatting + [tomgross] 1.4.1 (2018-10-22) diff --git a/src/collective/__init__.py b/src/collective/__init__.py index 68c04af..03d08ff 100644 --- a/src/collective/__init__.py +++ b/src/collective/__init__.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__import__('pkg_resources').declare_namespace(__name__) +__import__("pkg_resources").declare_namespace(__name__) diff --git a/src/collective/handlebars/__init__.py b/src/collective/handlebars/__init__.py index 831813c..78d73ef 100644 --- a/src/collective/handlebars/__init__.py +++ b/src/collective/handlebars/__init__.py @@ -3,4 +3,4 @@ from zope.i18nmessageid import MessageFactory -_ = MessageFactory('collective.handlebars') +_ = MessageFactory("collective.handlebars") diff --git a/src/collective/handlebars/browser/views.py b/src/collective/handlebars/browser/views.py index 1c1a3e2..9fd76f7 100644 --- a/src/collective/handlebars/browser/views.py +++ b/src/collective/handlebars/browser/views.py @@ -13,13 +13,17 @@ import sys try: - get_distribution('plone.tiles') -except DistributionNotFound: # pragma: no cover + get_distribution("plone.tiles") +except DistributionNotFound: # pragma: no cover + class Tile(BrowserView): """Fake Tile which is only a BrowserView""" + class PersistentTile(BrowserView): """Fake persistent Tile which is only a BrowserView""" -else: # pragma: no cover + + +else: # pragma: no cover from plone.tiles.tile import Tile from plone.tiles.tile import PersistentTile @@ -35,9 +39,8 @@ def package_home(gdict): class HandlebarsMixin: - def get_contents(self): - """ Get CMS data and put it in a JSON format for hbs inclusion + """Get CMS data and put it in a JSON format for hbs inclusion :return: dictonary (must not be a JSON structure! The conversion is handled by the templating engine) @@ -70,7 +73,7 @@ def _get_hbs_template(self, hbs_filename): return compiled_template def get_partials(self, hbs_dir): - """ Get partials for rendering the master hbs_template + """Get partials for rendering the master hbs_template :param hbs_dir: directory of master template (/home/vagrant/templates/) @@ -80,7 +83,7 @@ def get_partials(self, hbs_dir): return {} def get_helpers(self): - """ Get helpers for rendering the master hbs_template + """Get helpers for rendering the master hbs_template :return: dictonary with compiled partials templates ({'list': self.list_items()}) @@ -93,25 +96,26 @@ def hbs_snippet(self, filename=None, _prefix=None): path = self.get_path_from_prefix(_prefix) hbs_file = os.path.join(path, filename) if not os.path.isfile(hbs_file): - raise ValueError('No such file', hbs_file) - elif hasattr(self, 'index'): # noqa + raise ValueError("No such file", hbs_file) + elif hasattr(self, "index"): # noqa # second scenario: get snippet from zcml # reuse filename from tile definition in zcml but read file here # otherwise it is interpreted as XML/PT hbs_file = self.index.filename else: - raise ValueError('No template found!') + raise ValueError("No template found!") hbs_template = self._get_hbs_template(hbs_file) hbs_dir = os.path.dirname(hbs_file) partials = self.get_partials(hbs_dir) helpers = self.get_helpers() - self.request.response.setHeader("Content-type", - "text/html; charset=utf-8") - return hbs_template(self.get_contents(), - helpers=helpers, - partials=partials) + self.request.response.setHeader( + "Content-type", "text/html; charset=utf-8" + ) + return hbs_template( + self.get_contents(), helpers=helpers, partials=partials + ) def get_path_from_prefix(self, _prefix): if isinstance(_prefix, str): @@ -122,42 +126,51 @@ def get_path_from_prefix(self, _prefix): path = package_home(_prefix) return path - def translate(self, msgid, domain=None, mapping=None, context=None, - target_language=None, default=None): + def translate( + self, + msgid, + domain=None, + mapping=None, + context=None, + target_language=None, + default=None, + ): if not target_language: target_language = api.portal.get_current_language(context) - return translate(msgid=msgid, - domain=domain, - mapping=mapping, - context=context, - default=default, - target_language=target_language) + return translate( + msgid=msgid, + domain=domain, + mapping=mapping, + context=context, + default=default, + target_language=target_language, + ) def _wrap_widget(self, render): - if render and render.startswith(u''): + if render and render.startswith(u""): return render - return ''.join([u'
', render, u'
']) + return "".join([u"
", render, u"
"]) class HandlebarsBrowserView(BrowserView, HandlebarsMixin): - """ A simple browserview using hbs as templating engine""" + """A simple browserview using hbs as templating engine""" def __call__(self, *args, **kwargs): return self.hbs_snippet() class HandlebarsPloneView(BrowserView, HandlebarsMixin): - """ A hbs view rendered in the content slot of the main template of Plone - """ + """A hbs view rendered in the content slot of the main template of Plone""" - main_template = ViewPageTemplateFile('templates/plone_standard_template.pt') # noqa + main_template = ViewPageTemplateFile( + "templates/plone_standard_template.pt" + ) def __call__(self, *args, **kwargs): return self.main_template(*args, **kwargs) class HandlebarsTile(Tile, HandlebarsMixin): - def __call__(self, *args, **kwargs): return self._wrap_widget(self.hbs_snippet()) @@ -167,8 +180,8 @@ def __call__(self, *args, **kwargs): class HandlebarsPersistentTile(PersistentTile, HandlebarsMixin): - def __call__(self, *args, **kwargs): return self._wrap_widget(self.hbs_snippet()) + # EOF diff --git a/src/collective/handlebars/setuphandlers.py b/src/collective/handlebars/setuphandlers.py index 625480b..1ff7ad6 100644 --- a/src/collective/handlebars/setuphandlers.py +++ b/src/collective/handlebars/setuphandlers.py @@ -5,12 +5,11 @@ @implementer(INonInstallable) class HiddenProfiles(object): - def getNonInstallableProfiles(self): """Hide uninstall profile from site-creation and quickinstaller""" return [ - 'collective.handlebars:default', - 'collective.handlebars:uninstall', + "collective.handlebars:default", + "collective.handlebars:uninstall", ] diff --git a/src/collective/handlebars/testing.py b/src/collective/handlebars/testing.py index 45f60e3..ea4f152 100644 --- a/src/collective/handlebars/testing.py +++ b/src/collective/handlebars/testing.py @@ -2,12 +2,10 @@ from collective.handlebars.browser.views import HandlebarsBrowserView from collective.handlebars.browser.views import HandlebarsPloneView from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE -from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE from plone.app.testing import applyProfile from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PloneSandboxLayer -from plone.testing import z2 import collective.handlebars @@ -21,23 +19,23 @@ def setUpZope(self, app, configurationContext): # The z3c.autoinclude feature is disabled in the Plone fixture base # layer. self.loadZCML(package=collective.handlebars) - self.loadZCML(package=collective.handlebars, name='testing.zcml') + self.loadZCML(package=collective.handlebars, name="testing.zcml") def setUpPloneSite(self, portal): - applyProfile(portal, 'collective.handlebars:default') + applyProfile(portal, "collective.handlebars:default") class HBSTestView(HandlebarsBrowserView): - def get_contents(self): - return {'title': u'Fäncy Title', 'body': u'This is the body'} + return {"title": u"Fäncy Title", "body": u"This is the body"} class HBSTestPloneView(HandlebarsPloneView): - def get_contents(self): - return {'title': u'Fäncy Title', - 'body': u'This is the Plone View body'} + return { + "title": u"Fäncy Title", + "body": u"This is the Plone View body", + } COLLECTIVE_HANDLEBARS_FIXTURE = CollectiveHandlebarsLayer() @@ -45,21 +43,11 @@ def get_contents(self): COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING = IntegrationTesting( bases=(COLLECTIVE_HANDLEBARS_FIXTURE,), - name='CollectiveHandlebarsLayer:IntegrationTesting' + name="CollectiveHandlebarsLayer:IntegrationTesting", ) COLLECTIVE_HANDLEBARS_FUNCTIONAL_TESTING = FunctionalTesting( bases=(COLLECTIVE_HANDLEBARS_FIXTURE,), - name='CollectiveHandlebarsLayer:FunctionalTesting' -) - - -COLLECTIVE_HANDLEBARS_ACCEPTANCE_TESTING = FunctionalTesting( - bases=( - COLLECTIVE_HANDLEBARS_FIXTURE, - REMOTE_LIBRARY_BUNDLE_FIXTURE, - z2.ZSERVER_FIXTURE - ), - name='CollectiveHandlebarsLayer:AcceptanceTesting' + name="CollectiveHandlebarsLayer:FunctionalTesting", ) diff --git a/src/collective/handlebars/tests/test_setup.py b/src/collective/handlebars/tests/test_setup.py index 65a3ad1..1cab495 100644 --- a/src/collective/handlebars/tests/test_setup.py +++ b/src/collective/handlebars/tests/test_setup.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -from collective.handlebars.testing import COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING # noqa +from collective.handlebars.testing import ( + COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING, +) from plone import api import unittest @@ -11,9 +13,9 @@ except ImportError: # pragma: no cover # Quick shim for 5.1 api change - class get_installer(object): # noqa - def __init__(self, portal, request): # noqa - self.installer = api.portal.get_tool(name='portal_quickinstaller') + class get_installer(object): # noqa + def __init__(self, portal, request): # noqa + self.installer = api.portal.get_tool(name="portal_quickinstaller") def is_product_installed(self, name): return self.installer.isProductInstalled(name) @@ -29,19 +31,20 @@ class TestSetup(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] self.installer = get_installer(self.portal, self.layer["request"]) def test_product_installed(self): """Test if collective.handlebars is installed.""" - self.assertTrue(self.installer.is_product_installed( - 'collective.handlebars')) + self.assertTrue( + self.installer.is_product_installed("collective.handlebars") + ) def test_browserlayer(self): """Test that ICollectiveHandlebarsLayer is registered.""" - from collective.handlebars.interfaces import ( - ICollectiveHandlebarsLayer) + from collective.handlebars.interfaces import ICollectiveHandlebarsLayer from plone.browserlayer import utils + self.assertIn(ICollectiveHandlebarsLayer, utils.registered_layers()) @@ -50,27 +53,34 @@ class TestUninstall(unittest.TestCase): layer = COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING def setUp(self): - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] self.installer = get_installer(self.portal, self.layer["request"]) - self.installer.uninstall_product('collective.handlebars') + self.installer.uninstall_product("collective.handlebars") def test_product_uninstalled(self): """Test if collective.handlebars is cleanly uninstalled.""" - self.assertFalse(self.installer.is_product_installed( - 'collective.handlebars')) + self.assertFalse( + self.installer.is_product_installed("collective.handlebars") + ) def test_browserlayer_removed(self): """Test that ICollectiveHandlebarsLayer is removed.""" from collective.handlebars.interfaces import ICollectiveHandlebarsLayer from plone.browserlayer import utils + self.assertNotIn(ICollectiveHandlebarsLayer, utils.registered_layers()) def test_hiddenprofiles(self): - """ Test uninstall profile is hidden + """Test uninstall profile is hidden :return:None """ from collective.handlebars.setuphandlers import HiddenProfiles - self.assertIn('collective.handlebars:default', - HiddenProfiles().getNonInstallableProfiles()) - self.assertIn('collective.handlebars:uninstall', - HiddenProfiles().getNonInstallableProfiles()) + + self.assertIn( + "collective.handlebars:default", + HiddenProfiles().getNonInstallableProfiles(), + ) + self.assertIn( + "collective.handlebars:uninstall", + HiddenProfiles().getNonInstallableProfiles(), + ) diff --git a/src/collective/handlebars/tests/test_views.py b/src/collective/handlebars/tests/test_views.py index 29021b7..9a8b3a5 100644 --- a/src/collective/handlebars/tests/test_views.py +++ b/src/collective/handlebars/tests/test_views.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -from collective.handlebars.testing import COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING # noqa +from collective.handlebars.testing import ( + COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING, +) from collective.handlebars.browser.views import HandlebarsBrowserView from collective.handlebars.browser.views import HandlebarsTile from collective.handlebars.browser.views import HandlebarsPersistentTile @@ -15,67 +17,60 @@ import unittest -TEST_DATA__DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'data') -_ = MessageFactory('my.domain') +TEST_DATA__DIR = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "data" +) +_ = MessageFactory("my.domain") def normalize(stream): - return ' '.join([snippet.strip() for snippet in stream.split()]) + return " ".join([snippet.strip() for snippet in stream.split()]) class DummyHbsTile(HandlebarsTile): - def get_contents(self): - return {'src': 'foo', 'alt': 'bar'} + return {"src": "foo", "alt": "bar"} class DummyHbsPersistentTile(HandlebarsPersistentTile): - def get_contents(self): - return {'src': 'foo', 'alt': 'bar'} + return {"src": "foo", "alt": "bar"} class DummyHbsTemplate(object): - def __init__(self, filename): self.filename = filename @interface.implementer(ITranslationDomain) class TestDomain(dict): - def translate(self, text, *_, **__): return self[text], _[2] class DummyHbsFile(HandlebarsBrowserView): - def get_contents(self): - return {'title': u'File Test', - 'body': u'Hello HBS World!'} + return {"title": u"File Test", "body": u"Hello HBS World!"} def __call__(self): - return self.hbs_snippet('data/minimal.hbs') + return self.hbs_snippet("data/minimal.hbs") def invalid(self): - return self.hbs_snippet('data/minimal_notfound.hbs') + return self.hbs_snippet("data/minimal_notfound.hbs") class HelperHbsView(HandlebarsBrowserView): - def get_contents(self): - return {'title': u'File Test', - 'body': u'Hello HBS Wörld!'} + return {"title": u"File Test", "body": u"Hello HBS Wörld!"} def _myhelper(self, options, items): - return u'HELPER: ' + items + return u"HELPER: " + items def get_helpers(self): - return {'myhelper': self._myhelper} + return {"myhelper": self._myhelper} def __call__(self): - return self.hbs_snippet('data/helper.hbs') + return self.hbs_snippet("data/helper.hbs") class TestBrowserView(unittest.TestCase): @@ -85,66 +80,73 @@ class TestBrowserView(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" - self.portal = self.layer['portal'] - self.view = self.portal.restrictedTraverse('@@hbs_test_view') + self.portal = self.layer["portal"] + self.view = self.portal.restrictedTraverse("@@hbs_test_view") def test_get_contents_default(self): - """ Method `get_tile_data` is not implemented in base class + """Method `get_tile_data` is not implemented in base class :return: """ - view = HandlebarsBrowserView(self.portal, self.layer['request']) + view = HandlebarsBrowserView(self.portal, self.layer["request"]) self.assertRaises(NotImplementedError, view.get_contents) def test_base_view(self): - """ An error is raised, if no template is specified """ - view = HandlebarsBrowserView(self.portal, self.layer['request']) + """An error is raised, if no template is specified""" + view = HandlebarsBrowserView(self.portal, self.layer["request"]) self.assertRaises(ValueError, view) def test_example_view(self): """Test that a handlebars template is rendered.""" - view = self.portal.restrictedTraverse('@@hbs_test_view') - result_file = open(os.path.join(TEST_DATA__DIR, 'minimal.html')) + view = self.portal.restrictedTraverse("@@hbs_test_view") + result_file = open(os.path.join(TEST_DATA__DIR, "minimal.html")) self.assertEqual(view(), six.ensure_text(result_file.read())) def test_translate(self): - view = HandlebarsBrowserView(self.portal, self.layer['request']) - component.provideUtility(TestDomain(Allowed=_('Erlaubt')), - provides=ITranslationDomain, - name='my.domain') - self.assertEqual(view.translate(_('Allowed'), target_language='de'), - (u'Erlaubt', 'de')) + view = HandlebarsBrowserView(self.portal, self.layer["request"]) + component.provideUtility( + TestDomain(Allowed=_("Erlaubt")), + provides=ITranslationDomain, + name="my.domain", + ) + self.assertEqual( + view.translate(_("Allowed"), target_language="de"), + (u"Erlaubt", "de"), + ) def test_translate_default_lang(self): - view = HandlebarsBrowserView(self.portal, self.layer['request']) - component.provideUtility(TestDomain(Allowed=_('Allowed')), - provides=ITranslationDomain, - name='my.domain') - self.assertEqual(view.translate(_('Allowed')), (u'Allowed', 'en')) + view = HandlebarsBrowserView(self.portal, self.layer["request"]) + component.provideUtility( + TestDomain(Allowed=_("Allowed")), + provides=ITranslationDomain, + name="my.domain", + ) + self.assertEqual(view.translate(_("Allowed")), (u"Allowed", "en")) def test_hbs_snippet(self): - view = DummyHbsFile(self.portal, self.layer['request']) - result_file = open(os.path.join(TEST_DATA__DIR, 'minimal_file.html')) + view = DummyHbsFile(self.portal, self.layer["request"]) + result_file = open(os.path.join(TEST_DATA__DIR, "minimal_file.html")) self.assertEqual(view(), six.ensure_text(result_file.read())) def test_hbs_snippet_nofile(self): - view = DummyHbsFile(self.portal, self.layer['request']) + view = DummyHbsFile(self.portal, self.layer["request"]) self.assertRaises(ValueError, view.invalid) def test_get_path_from_prefix(self): - view = DummyHbsFile(self.portal, self.layer['request']) - self.assertEqual(view.get_path_from_prefix(_prefix='.'), '.') + view = DummyHbsFile(self.portal, self.layer["request"]) + self.assertEqual(view.get_path_from_prefix(_prefix="."), ".") def test_helpers(self): - view = HelperHbsView(self.portal, self.layer['request']) - result_file = open(os.path.join(TEST_DATA__DIR, 'helper.html')) + view = HelperHbsView(self.portal, self.layer["request"]) + result_file = open(os.path.join(TEST_DATA__DIR, "helper.html")) self.assertEqual(view(), six.ensure_text(result_file.read())) def test_render_helper(self): - view = HandlebarsBrowserView(self.portal, self.layer['request']) - rendered = view._wrap_widget('Hello unittest') + view = HandlebarsBrowserView(self.portal, self.layer["request"]) + rendered = view._wrap_widget("Hello unittest") self.assertEqual( - rendered, '
Hello unittest
') + rendered, "
Hello unittest
" + ) class TestPloneView(unittest.TestCase): @@ -154,34 +156,31 @@ class TestPloneView(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" - self.portal = self.layer['portal'] - self.view = self.portal.restrictedTraverse('@@hbs_test_ploneview') + self.portal = self.layer["portal"] + self.view = self.portal.restrictedTraverse("@@hbs_test_ploneview") def test_get_contents_default(self): - """ Method `get_tile_data` is not implemented in base class + """Method `get_tile_data` is not implemented in base class :return: """ - view = HandlebarsBrowserView(self.portal, self.layer['request']) + view = HandlebarsBrowserView(self.portal, self.layer["request"]) self.assertRaises(NotImplementedError, view.get_contents) def test_base_view(self): - """ An error is raised, if no template is specified """ - view = HandlebarsBrowserView(self.portal, self.layer['request']) + """An error is raised, if no template is specified""" + view = HandlebarsBrowserView(self.portal, self.layer["request"]) self.assertRaises(ValueError, view) def test_example_view(self): """Test that a handlebars template is rendered.""" - view = self.portal.restrictedTraverse('@@hbs_test_ploneview') - if api.env.plone_version().startswith('5.0'): - filename = os.path.join(TEST_DATA__DIR, 'minimal_plone.html') + view = self.portal.restrictedTraverse("@@hbs_test_ploneview") + 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') + filename = os.path.join(TEST_DATA__DIR, "minimal_plone_51.html") with open(filename) as f: - self.assertIn( - six.ensure_text(f.read().strip()), - normalize(view()) - ) + self.assertIn(six.ensure_text(f.read().strip()), normalize(view())) class TestHandlebarTile(unittest.TestCase): @@ -190,49 +189,53 @@ class TestHandlebarTile(unittest.TestCase): layer = COLLECTIVE_HANDLEBARS_INTEGRATION_TESTING def setUp(self): - self.tile = HandlebarsTile(self.layer['portal'], self.layer['request']) - self.template_path = os.path.join(TEST_DATA__DIR, - '_slideshow_slide.js.hbs') + self.tile = HandlebarsTile(self.layer["portal"], self.layer["request"]) + self.template_path = os.path.join( + TEST_DATA__DIR, "_slideshow_slide.js.hbs" + ) def test_get_contents_default(self): - """ Method `get_tile_data` is not implemented in base class + """Method `get_tile_data` is not implemented in base class :return: """ - view = HandlebarsBrowserView(self.layer['portal'], - self.layer['request']) + view = HandlebarsBrowserView( + self.layer["portal"], self.layer["request"] + ) self.assertRaises(NotImplementedError, view.get_contents) def test_get_hbs_template(self): template = self.tile._get_hbs_template(self.template_path) self.assertEqual( - template({'src': 'foo', 'alt': 'bar'}).strip(), - u'bar' + template({"src": "foo", "alt": "bar"}).strip(), + u'bar', ) def test_get_partial_key(self): - self.assertEqual(self.tile._get_partial_key(self.template_path), - '_slideshow_slide.js') + self.assertEqual( + self.tile._get_partial_key(self.template_path), + "_slideshow_slide.js", + ) def test_call_notemplate(self): - """ An error is raised, if no template is specified """ + """An error is raised, if no template is specified""" self.assertRaises(ValueError, self.tile) def test_call_with_template(self): - tile = DummyHbsTile(self.layer['portal'], self.layer['request']) - setattr(tile, 'index', DummyHbsTemplate(self.template_path)) + tile = DummyHbsTile(self.layer["portal"], self.layer["request"]) + setattr(tile, "index", DummyHbsTemplate(self.template_path)) self.assertEqual( normalize(tile()), - u'
bar
' + u'
bar
', ) def test_call_with_body_template(self): - template_path = os.path.join(TEST_DATA__DIR, 'body_tile.hbs') - tile = DummyHbsTile(self.layer['portal'], self.layer['request']) - setattr(tile, 'index', DummyHbsTemplate(template_path)) + template_path = os.path.join(TEST_DATA__DIR, "body_tile.hbs") + tile = DummyHbsTile(self.layer["portal"], self.layer["request"]) + setattr(tile, "index", DummyHbsTemplate(template_path)) self.assertEqual( tile().strip(), - u'' + u'', ) @@ -243,38 +246,43 @@ class TestHandlebarPersistentTile(unittest.TestCase): def setUp(self): self.tile = HandlebarsPersistentTile( - self.layer['portal'], self.layer['request']) - self.template_path = os.path.join(TEST_DATA__DIR, - '_slideshow_slide.js.hbs') + self.layer["portal"], self.layer["request"] + ) + self.template_path = os.path.join( + TEST_DATA__DIR, "_slideshow_slide.js.hbs" + ) def test_get_contents_default(self): - """ Method `get_tile_data` is not implemented in base class + """Method `get_tile_data` is not implemented in base class :return: """ - view = HandlebarsBrowserView(self.layer['portal'], - self.layer['request']) + view = HandlebarsBrowserView( + self.layer["portal"], self.layer["request"] + ) self.assertRaises(NotImplementedError, view.get_contents) def test_get_hbs_template(self): template = self.tile._get_hbs_template(self.template_path) self.assertEqual( - template({'src': 'foo', 'alt': 'bar'}).strip(), - u'bar' + template({"src": "foo", "alt": "bar"}).strip(), + u'bar', ) def test_get_partial_key(self): - self.assertEqual(self.tile._get_partial_key(self.template_path), - '_slideshow_slide.js') + self.assertEqual( + self.tile._get_partial_key(self.template_path), + "_slideshow_slide.js", + ) def test_call_notemplate(self): - """ An error is raised, if no template is specified """ + """An error is raised, if no template is specified""" self.assertRaises(ValueError, self.tile) def test_call_with_template(self): - tile = DummyHbsTile(self.layer['portal'], self.layer['request']) - setattr(tile, 'index', DummyHbsTemplate(self.template_path)) + tile = DummyHbsTile(self.layer["portal"], self.layer["request"]) + setattr(tile, "index", DummyHbsTemplate(self.template_path)) self.assertEqual( normalize(tile()), - u'
bar
' + u'
bar
', )