Esempio n. 1
0
    def test_exception_raised_for_unknown_node(self):
        compiler = JinjaToJS(template_root=self.TEMPLATE_PATH,
                             template_name='if.jinja')

        class FakeNode(object):
            pass

        fake_node = FakeNode()

        with pytest.raises(Exception) as e:
            compiler._process_node(fake_node)

        assert str(e.value) == 'Unknown node %s' % fake_node
Esempio n. 2
0
    def test_exception_raised_for_unknown_node(self):
        compiler = JinjaToJS(template_root=self.TEMPLATE_PATH,
                             template_name='if.jinja')

        class FakeNode(object):
            pass

        fake_node = FakeNode()

        with pytest.raises(Exception) as e:
            compiler._process_node(fake_node)

        assert str(e.value) == 'Unknown node %s' % fake_node
Esempio n. 3
0
    def _compile_js_template(self, name):
        js_module = JinjaToJS(template_root=self.TEMPLATE_PATH,
                              template_name=name,
                              js_module_format='commonjs',
                              runtime_path=abspath('jinja-to-js-runtime.js'),
                              custom_filters=['unicode_snowmen']).get_output()

        target = self.temp_dir + '/' + os.path.splitext(name)[0] + '.js'

        if not os.path.exists(os.path.dirname(target)):
            os.makedirs(os.path.dirname(target))

        with open(target, 'wb') as f:
            f.write(js_module.encode('utf-8'))

        return target
Esempio n. 4
0
    def test_slice_with_step_raises(self):

        with pytest.raises(Exception) as e:
            JinjaToJS(template_root=self.TEMPLATE_PATH,
                      template_name='slice_with_step.jinja')

        assert str(
            e.value) == 'The step argument is not supported when slicing.'
Esempio n. 5
0
    def _compile_js_template(self, name):
        js_module = JinjaToJS(
            template_root=self.TEMPLATE_PATH,
            template_name=name,
            js_module_format='commonjs',
            runtime_path=abspath('jinja-to-js-runtime.js'),
            custom_filters=['unicode_snowmen']
        ).get_output()

        target = self.temp_dir + '/' + os.path.splitext(name)[0] + '.js'

        if not os.path.exists(os.path.dirname(target)):
            os.makedirs(os.path.dirname(target))

        with open(target, 'wb') as f:
            f.write(js_module.encode('utf-8'))

        return target
Esempio n. 6
0
    def test_constructor_exceptions(self):

        with pytest.raises(TemplateNotFound):
            JinjaToJS(template_root=self.TEMPLATE_PATH,
                      template_name='does/not/exist.jinja')
Esempio n. 7
0
 def test_super_called_outside_of_block(self):
     with pytest.raises(Exception) as e:
         JinjaToJS(template_root=self.TEMPLATE_PATH,
                   template_name='super_called_outside_of_block.jinja')
     assert str(
         e.value) == 'super() called outside of a block with a parent.'
Esempio n. 8
0
 def test_exception_raised_for_unknown_filter(self):
     with pytest.raises(Exception) as e:
         JinjaToJS(template_root=self.TEMPLATE_PATH,
                   template_name='unsupported_filter.jinja')
     assert str(e.value) == 'Unsupported filter: somefilter'
    def test_constructor_exceptions(self):

        with pytest.raises(TemplateNotFound):
            JinjaToJS(loader=self.loader, template_name='does/not/exist.jinja')
Esempio n. 10
0
 def test_exception_raised_for_unknown_test(self):
     with pytest.raises(Exception) as e:
         JinjaToJS(loader=self.loader, template_name='unsupported_test.jinja')
     assert str(e.value) == 'Unsupported test: someunknowntest'