Exemple #1
0
 def test_findingTemplate(self):
     t = Template(self.zp)
     t.dest_file = 'foo.py'
     t.tfile = 'foo.py.tmpl'
     self.source_template = 'foo.tmpl'
     t.findTemplate()
     self.assertEqual(t.tfile, "%s/Templates/%s" %
                      ("/".join(inspect.getfile(zpg).split('/')[:-1]), t.source_template))
Exemple #2
0
 def test_findCachedLocation(self):
     t = Template(self.zp)
     exists = os.path.exists
     os.path.exists = MagicMock(return_value=True)
     t.dest_file = 'foo.py'
     t.tfile = 'foo.py.tmpl'
     self.source_template = 'foo.tmpl'
     t.findTemplate()
     self.assertEqual(t.tfile, t.TemplateCacheLocation())
     os.path.exists = exists
Exemple #3
0
    def testCaching(self):
        m = mock_open()
        os.makedirs = MagicMock(return_value=True)
        with patch('__builtin__.open', mock_open(read_data='Source Template'), create=True) as m:
            t = Template(self.zp)
            t.dest_file = 'foo.py'
            t.tfile = 'foo.py.tmpl'
            t.cacheTemplate()

        # Write File Handle
        wfh = m.return_value.__enter__.return_value
        self.assertEqual(wfh.write.call_args_list, [
                         call('## Source Template foo.py.tmpl \n'), call('Source Template')])