Esempio n. 1
0
    def test_customize_global_reenable(self):
        self._mkfile1(self.file1)
        self._mkfile2(self.file2)

        f = open(os.path.join(self.dir2, 'test'), 'wb')
        f.write(' ')
        f.close()

        tmpl = view.template(os.path.join(self.dir1, 'file.pt'))
        self.assertEqual(tmpl(), '<div>Test template 1</div>')

        # load without watcher
        self._init_memphis({'template.custom': os.path.join(self.dir2, 'test')})

        self.assertTrue(customize.TEMPLATE._manager is None)
        self.assertTrue(customize.TEMPLATE._watcher is None)
        self.assertEqual(tmpl(), '<div>Test template 1</div>')

        # reinitialize
        customize.TEMPLATE['custom'] = self.dir2
        customize.TEMPLATE['watcher'] = ''
        customize.initialize(config.SettingsInitializing(object()))

        self.assertTrue(customize.TEMPLATE._manager is not None)
        self.assertTrue(customize.TEMPLATE._watcher is None)

        self.assertEqual(tmpl(), '<div>Test template 2</div>')
Esempio n. 2
0
    def test_customize_global_disable(self):
        self._mkfile1(self.file1)
        self._mkfile2(self.file2)

        tmpl = view.template(os.path.join(self.dir1, 'file.pt'))
        self.assertEqual(tmpl(), '<div>Test template 1</div>')

        # enable custom folder
        self._init_memphis({'template.custom': self.dir2})
        self.assertEqual(tmpl(), '<div>Test template 2</div>')

        customize.TEMPLATE['custom'] = ''
        customize.initialize(config.SettingsInitializing(None))

        self.assertTrue(customize.TEMPLATE._manager is None)
        self.assertTrue(customize.TEMPLATE._watcher is None)
        self.assertEqual(tmpl(), '<div>Test template 1</div>')