def test_empty(self): build_dir = mkdtemp(self) spec = Spec( build_dir=build_dir, plugin_sourcepath={}, bundle_sourcepath={}, ) precompile_nunja(spec, False, 'plugin_sourcepath', 'bundle_sourcepath') self.assertFalse(exists(join(build_dir, '__nunja_precompiled__.js'))) self.assertNotIn('nunjucks', spec['bundle_sourcepath'])
def test_missing_keys(self): build_dir = mkdtemp(self) spec = Spec(build_dir=build_dir, ) with self.assertRaises(AdviceAbort) as e: precompile_nunja(spec, False, 'myplugin_sourcepath', 'mybundle_sourcepath') self.assertEqual( e.exception.args[0], 'cannot precompile_nunja if spec is missing keys ' '{mybundle_sourcepath, myplugin_sourcepath}')
def test_nunjucks_slim_empty_unspecified(self): nunjucks_path = 'empty:' build_dir = mkdtemp(self) spec = Spec( build_dir=build_dir, plugin_sourcepath={}, bundle_sourcepath={ 'nunjucks': nunjucks_path, }, ) precompile_nunja(spec, True, 'plugin_sourcepath', 'bundle_sourcepath') self.assertNotEqual(spec['bundle_sourcepath']['nunjucks'], 'empty:')
def test_nunjucks(self): nunjucks_path = join('node_modules', 'nunjucks', 'nunjucks.js'), build_dir = mkdtemp(self) spec = Spec( build_dir=build_dir, plugin_sourcepath={}, bundle_sourcepath={ 'nunjucks': nunjucks_path, }, ) precompile_nunja(spec, False, 'plugin_sourcepath', 'bundle_sourcepath') self.assertFalse(exists(join(build_dir, '__nunja_precompiled__.js'))) self.assertEqual(spec['bundle_sourcepath']['nunjucks'], nunjucks_path)
def test_nunjucks_slim_empty_specified(self): nunjucks_path = 'about:blank' build_dir = mkdtemp(self) spec = Spec( build_dir=build_dir, plugin_sourcepath={}, bundle_sourcepath={ 'nunjucks': nunjucks_path, }, ) precompile_nunja(spec, True, 'plugin_sourcepath', 'bundle_sourcepath', omit_paths=('about:blank', )) self.assertEqual(spec['bundle_sourcepath']['nunjucks'], 'about:blank')
def test_stubbed_empty(self): build_dir = mkdtemp(self) spec = Spec( build_dir=build_dir, plugin_sourcepath={ 'text!demo/template.nja': 'empty:', }, bundle_sourcepath={}, ) with pretty_logging('nunja', stream=StringIO()) as stream: precompile_nunja(spec, True, 'plugin_sourcepath', 'bundle_sourcepath', omit_paths=('empty:', )) self.assertNotIn('failed', stream.getvalue()) self.assertFalse(exists(join(build_dir, '__nunja_precompiled__.js'))) self.assertNotIn('nunjucks', spec['bundle_sourcepath'])