def test_extends(self):
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'child_base', 'child.html')))
        main(os.path.join(fixtures_dir, 'child_base'))
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'child_base', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'child_base', 'child.html')).read()
        self.assertEquals(file_content, 'begin parent\nparent content\n\nchild content\nend parent')
    def test_extends_and_include(self):
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        main(os.path.join(fixtures_dir, 'header_footer'))
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'header_footer', 'child.html')).read()
        self.assertEquals(file_content, 'header!\nbegin parent\nparent content\n\nchild content\nend parent\nfooter!')
    def test_extends_and_include(self):
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        main(os.path.join(fixtures_dir, 'header_footer'))
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'header_footer', 'child.html')).read()
        self.assertEquals(file_content, 'header!\nbegin parent\nparent content\n\nchild content\nend parent\nfooter!')
    def test_extends(self):
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'child_base', 'child.html')))
        main(os.path.join(fixtures_dir, 'child_base'))
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'child_base', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'child_base', 'child.html')).read()
        self.assertEquals(file_content, 'begin parent\nparent content\n\nchild content\nend parent')
    def test_ignore_jinja_templates(self):
        Settings = namedtuple('Settings', ['IGNORE_JINJA_TEMPLATES'])
        settings = Settings(IGNORE_JINJA_TEMPLATES=['.*base.jinja', ])

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'base.html')))
        main(os.path.join(fixtures_dir, 'header_footer'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'base.html')))
    def test_ignore_jinja_templates(self):
        Settings = namedtuple('Settings', ['IGNORE_JINJA_TEMPLATES'])
        settings = Settings(IGNORE_JINJA_TEMPLATES=['.*base.jinja', ])

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'base.html')))
        main(os.path.join(fixtures_dir, 'header_footer'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'child.html')))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'header_footer', 'base.html')))
    def test_undefined_vars_raises_errors(self):
        Settings = namedtuple('Settings', ['EXTRA_VARIABLES'])
        settings = Settings(EXTRA_VARIABLES={'name': 'Filipe Waitman'})

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
        self.assertRaises(UndefinedError, main, path=os.path.join(fixtures_dir, 'undefined_vars'))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
        main(os.path.join(fixtures_dir, 'undefined_vars'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
    def test_extends_and_include_and_custom_vars(self):
        Settings = namedtuple('Settings', ['EXTRA_VARIABLES'])
        settings = Settings(EXTRA_VARIABLES={'number': 42, 'triplicate': lambda x: x * 3})

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'custom_vars', 'child.html')))
        main(os.path.join(fixtures_dir, 'custom_vars'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'custom_vars', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'custom_vars', 'child.html')).read()
        self.assertEquals(file_content, 'header!\nbegin parent\nparent content\n\nchild content\nworks! works! works! '
                                        '\n42 * 2 = 84\nend parent\nfooter!')
    def test_undefined_vars_raises_errors(self):
        Settings = namedtuple('Settings', ['EXTRA_VARIABLES'])
        settings = Settings(EXTRA_VARIABLES={'name': 'Filipe Waitman'})

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
        self.assertRaises(UndefinedError, main, path=os.path.join(fixtures_dir, 'undefined_vars'))
        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
        main(os.path.join(fixtures_dir, 'undefined_vars'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'undefined_vars', 'child.html')))
    def test_extends_and_include_and_custom_vars(self):
        Settings = namedtuple('Settings', ['EXTRA_VARIABLES'])
        settings = Settings(EXTRA_VARIABLES={'number': 42, 'triplicate': lambda x: x * 3})

        self.assertFalse(os.path.exists(os.path.join(fixtures_dir, 'custom_vars', 'child.html')))
        main(os.path.join(fixtures_dir, 'custom_vars'), settings=settings)
        self.assertTrue(os.path.exists(os.path.join(fixtures_dir, 'custom_vars', 'child.html')))

        file_content = open(os.path.join(fixtures_dir, 'custom_vars', 'child.html')).read()
        self.assertEquals(file_content, 'header!\nbegin parent\nparent content\n\nchild content\nworks! works! works! '
                                        '\n42 * 2 = 84\nend parent\nfooter!')