Exemple #1
0
    def test_abstract_component_not_visible(self):
        class AbstractComponent(Component):
            abstract = True
        class NotAbstractComponent(Component):
            abstract = False

        panel = PluginAdminPanel(self.env)
        data = panel.render_admin_panel(self.req, 'general', 'plugin', None)[1]

        module = self.__class__.__module__
        components = []
        for plugin in data['plugins']:
            if module in plugin['modules'].keys():
                components = plugin['modules'][module]['components'].keys()
        self.assertNotIn('AbstractComponent', components)
        self.assertIn('NotAbstractComponent', components)
Exemple #2
0
    def test_abstract_component_not_visible(self):
        class AbstractComponent(Component):
            abstract = True

        class NotAbstractComponent(Component):
            abstract = False

        panel = PluginAdminPanel(self.env)
        data = panel.render_admin_panel(self.req, "general", "plugin", None)[1]

        module = self.__class__.__module__
        components = []
        for plugin in data["plugins"]:
            if module in plugin["modules"].keys():
                components = plugin["modules"][module]["components"].keys()
        self.assertNotIn("AbstractComponent", components)
        self.assertIn("NotAbstractComponent", components)
Exemple #3
0
    def test_single_file_plugin_metadata(self):
        """Metadata is read from single-file plugins."""
        plugin_metadata = {
            'author': 'Trac Hacks',
            'author_email': '*****@*****.**',
            'home_page': 'https://trac-hacks.org/wiki/SingleFilePlugin',
            'license': 'BSD',
            'summary': 'The single-file plugin',
            'trac': 'https://my.trac.com',
        }
        plugin_content = """\
from trac.core import Component

author = '%(author)s'
author_email = '%(author_email)s'
home_page = '%(home_page)s'
license = '%(license)s'
summary = '%(summary)s'
trac = '%(trac)s'


class SingleFilePlugin(Component):
    pass
""" % plugin_metadata

        file_path = os.path.join(self.env.plugins_dir, 'single_file_plugin.py')
        os.mkdir(self.env.plugins_dir)
        create_file(file_path, plugin_content)
        load_components(self.env, (self.env.plugins_dir, ))

        req = MockRequest(self.env)
        panel = PluginAdminPanel(self.env)
        data = panel.render_admin_panel(req, 'general', 'plugin', None)[1]

        discovered_metadata = {}
        for item in data['plugins']:
            if item['name'] == 'single-file-plugin':
                discovered_metadata = item['info']

        for key, value in plugin_metadata.items():
            self.assertEqual(discovered_metadata[key], plugin_metadata[key])