def test_render_files_in_dir(self, walk_mock, remove_mock, render_mock,
                                 copy_permissions_mock):
        dir_path = '/tmp/some_plugin'
        walk_mock.return_value = [[
            dir_path, '', ['file1.txt.mako', 'file2.txt']
        ], [dir_path, '', ['file3', 'file4.mako']]]
        params = {'param1': 'value1', 'param2': 'value2'}

        utils.render_files_in_dir(dir_path, params)

        self.assertEqual([
            mock.call('/tmp/some_plugin/file1.txt.mako',
                      '/tmp/some_plugin/file1.txt', params),
            mock.call('/tmp/some_plugin/file4.mako', '/tmp/some_plugin/file4',
                      params)
        ], render_mock.call_args_list)

        self.assertEqual([
            mock.call('/tmp/some_plugin/file1.txt.mako'),
            mock.call('/tmp/some_plugin/file4.mako')
        ], remove_mock.call_args_list)

        self.assertEqual([
            mock.call('/tmp/some_plugin/file1.txt.mako',
                      '/tmp/some_plugin/file1.txt'),
            mock.call('/tmp/some_plugin/file4.mako', '/tmp/some_plugin/file4')
        ], copy_permissions_mock.call_args_list)
Exemple #2
0
    def test_render_files_in_dir(
            self, walk_mock, remove_mock, render_mock, copy_permissions_mock):
        dir_path = '/tmp/some_plugin'
        walk_mock.return_value = [
            [dir_path, '', ['file1.txt.mako', 'file2.txt']],
            [dir_path, '', ['file3', 'file4.mako']]]
        params = {'param1': 'value1', 'param2': 'value2'}

        utils.render_files_in_dir(dir_path, params)

        self.assertEqual(
            [mock.call('/tmp/some_plugin/file1.txt.mako',
                       '/tmp/some_plugin/file1.txt',
                       params),
             mock.call('/tmp/some_plugin/file4.mako',
                       '/tmp/some_plugin/file4',
                       params)],
            render_mock.call_args_list)

        self.assertEqual(
            [mock.call('/tmp/some_plugin/file1.txt.mako'),
             mock.call('/tmp/some_plugin/file4.mako')],
            remove_mock.call_args_list)

        self.assertEqual(
            [mock.call('/tmp/some_plugin/file1.txt.mako',
                       '/tmp/some_plugin/file1.txt'),
             mock.call('/tmp/some_plugin/file4.mako',
                       '/tmp/some_plugin/file4')],
            copy_permissions_mock.call_args_list)
Exemple #3
0
    def run(self):
        logger.debug('Start plugin creation "%s"', self.plugin_path)
        self.check()

        template_dir = os.path.join(
            os.path.dirname(__file__), '..', self.template_path)

        utils.copy(template_dir, self.plugin_path)
        utils.render_files_in_dir(self.plugin_path, self.render_ctx)
Exemple #4
0
    def run(self):
        logger.debug('Start plugin creation "%s"', self.plugin_path)
        self.check()

        for template_path in self.template_paths:

            template_dir = os.path.join(
                os.path.dirname(__file__), '..', template_path)

            utils.copy(template_dir, self.plugin_path)
            utils.render_files_in_dir(self.plugin_path, self.render_ctx)