예제 #1
0
파일: tests.py 프로젝트: iarriaga/pystatic
class TestTemplateRenderer(unittest.TestCase):


    def setUp(self):
        self.template_renderer = TemplateRenderer()
        self.correct_template = 'test.html'
        self.template_context = { 'macanudo': '2' }
        self.target_path = '/tmp/test.html'

    def test_correct_template(self):
        result = self.template_renderer.render(self.correct_template, self.template_context)
        self.assertEquals(result, 'Test template 2')

    def test_unexisting_template(self):
        try:
            result = self.template_renderer.render('testnotexisting.html')
            self.fail()
        except TemplateNotFound:
            pass

    def test_correct_template_with_file(self):
        self.template_renderer.render(self.correct_template, template_context \
                                          = self.template_context, target_path=self.target_path)
        target_file = open(self.target_path,'r')
        self.assertEquals(target_file.read(), 'Test template 2')
예제 #2
0
파일: tests.py 프로젝트: iarriaga/pystatic
 def setUp(self):
     self.template_renderer = TemplateRenderer()
     self.correct_template = 'test.html'
     self.template_context = { 'macanudo': '2' }
     self.target_path = '/tmp/test.html'