def test_route_err_in_template(self, m_log): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle('test-bundle', 'pyramid_amdjs:tests/bundle3/') self.request.matchdict['name'] = 'test-bundle' bundle_view(self.request) arg = m_log.error.call_args[0][0] self.assertTrue(arg.startswith('Compilation is failed')) self.assertTrue(arg.endswith('tests/bundle3/form.hb'))
def test_route_err_in_template(self, m_log): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle( 'test-bundle', 'pyramid_amdjs:tests/bundle3/') self.request.matchdict['name'] = 'test-bundle' bundle_view(self.request) arg = m_log.error.call_args[0][0] self.assertTrue(arg.startswith('Compilation is failed')) self.assertTrue(arg.endswith('tests/bundle3/form.hb'))
def test_unknown_bundle(self): from pyramid_amdjs.handlebars import bundle_view self.request.matchdict['name'] = 'unknown' res = bundle_view(self.request) self.assertIsInstance(res, HTTPNotFound)
def test_build_bundle_toplevel_i18n_no_nodejs(self, m_loc, m_com): from pyramid_amdjs.handlebars import bundle_view cfg = self.registry.settings cfg['amd.tmpl-langs'] = ['en', 'pt_BR'] self.config.add_handlebars_bundle('test-bundle', 'pyramid_amdjs:tests/bundle2/', i18n_domain='pyramid') self.request.matchdict['name'] = 'test-bundle' class loc(object): def translate(self, t, i18n): if m_loc.call_args[0][0].locale_name == 'pt_BR': return 'Senha' return t m_loc.return_value = loc() m_com.NODE_PATH = None res = bundle_view(self.request) self.assertIn("Handlebars.registerHelper('i18n-test-bundle'", res.text) self.assertIn( 'var bundle=new templates.Bundle("test-bundle",' '{"form":Handlebars.compile(', res.text) self.assertIn('bundle.__i18n__ = {"Password": {"pt_BR": "Senha"}}', res.text)
def test_build_bundle_toplevel_i18n_no_nodejs(self, m_loc, m_com): from pyramid_amdjs.handlebars import bundle_view cfg = self.registry.settings cfg['amd.tmpl-langs'] = ['en', 'pt_BR'] self.config.add_handlebars_bundle( 'test-bundle', 'pyramid_amdjs:tests/bundle2/', i18n_domain='pyramid') self.request.matchdict['name'] = 'test-bundle' class loc(object): def translate(self, t, i18n): if m_loc.call_args[0][0].locale_name == 'pt_BR': return 'Senha' return t m_loc.return_value = loc() m_com.NODE_PATH = None res = bundle_view(self.request) self.assertIn( "Handlebars.registerHelper('i18n-test-bundle'", res.text) self.assertIn( 'var bundle=new templates.Bundle("test-bundle",' '{"form":Handlebars.compile(', res.text) self.assertIn( 'bundle.__i18n__ = {"Password": {"pt_BR": "Senha"}}', res.text)
def test_build_bundle(self): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle('test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' res = bundle_view(self.request) self.assertIn('"form-window":Handlebars.template(function', res.text)
def test_build_bundle(self): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle( 'test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' res = bundle_view(self.request) self.assertIn( '"form-window":Handlebars.template(function', res.text)
def test_route(self): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle('test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' res = bundle_view(self.request) self.assertIn('"test-bundle",["pyramid:templates","handlebars"],', res.text) self.assertIn('"cat2":new templates.Bundle("cat2",{"form2"', res.text)
def test_build_bundle_no_node(self, m_comp): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle('test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' m_comp.NODE_PATH = None res = bundle_view(self.request) self.assertIn('form-window":Handlebars.compile("<div class=', res.text)
def test_route(self): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle( 'test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' res = bundle_view(self.request) self.assertIn( '"test-bundle",["pyramid:templates","handlebars"],', res.text) self.assertIn( '"cat2":new templates.Bundle("cat2",{"form2"', res.text)
def test_build_bundle_no_node(self, m_comp): from pyramid_amdjs.handlebars import bundle_view self.config.add_handlebars_bundle( 'test-bundle', 'pyramid_amdjs:tests/bundle/') self.request.matchdict['name'] = 'test-bundle' m_comp.NODE_PATH = None res = bundle_view(self.request) self.assertIn( 'form-window":Handlebars.compile("<div class=', res.text)