Exemplo n.º 1
0
 def help(self):
     """
     Show information about loaded plugins.
     :return: Information
     :rtype: str
     """
     return loaded(self.container, Actions())
Exemplo n.º 2
0
 def help(self):
     """
     Show information about loaded plugins.
     :return: Information
     :rtype: str
     """
     return loaded(self.container, Actions())
Exemplo n.º 3
0
    def test_loaded(self, actions):
        catalog = {
            Dog.__name__:
            Class(Dog,
                  methods={n: Method(m)
                           for n, m in inspection.methods(Dog)}),
            'stuff':
            Module('stuff',
                   functions={
                       bar1.__name__: Function(bar1),
                       bar2.__name__: Function(bar2),
                       bar3.__name__: Function(bar3),
                   })
        }
        plugins = [
            Plugin('animals', True, Mock(catalog=catalog)),
            Plugin('fish', False, None),
        ]

        container = Mock()
        container.all.return_value = plugins

        actions.collated.return_value = [
            Action('report', None, hours=24),
            Action('reboot', None, minutes=10)
        ]

        # test
        actual = loaded(container, actions)

        # validation
        expected = HELP % {'plugin': plugins[0].name}
        self.assertEqual(expected, actual)
Exemplo n.º 4
0
    def test_help(self, is_mod, is_fn):
        is_mod.side_effect = lambda thing: thing == Module
        is_fn.return_value = True
        container = Mock()
        actions = Mock()
        actions.collated.return_value = [
            Action('report', dict(hours=24)),
            Action('reboot', dict(minutes=10)),
        ]
        dispatcher = Mock(catalog={
            'dog': Dog,
            'mod': Module,
        })
        plugins = [
            Plugin('animals', True, dispatcher),
            Plugin('fish', False, None),
        ]
        container.all.return_value = plugins

        # test
        s = loaded(container, actions)

        # validation
        self.assertEqual(s, HELP % {'plugin': plugins[0].name})
Exemplo n.º 5
0
    def test_help(self, is_mod, is_fn):
        is_mod.side_effect = lambda thing: thing == Module
        is_fn.return_value = True
        container = Mock()
        actions = Mock()
        actions.collated.return_value = [
            Action('report', dict(hours=24)),
            Action('reboot', dict(minutes=10)),
        ]
        dispatcher = Mock(catalog={
            'dog': Dog,
            'mod': Module,
        })
        plugins = [
            Plugin('animals', True, dispatcher),
            Plugin('fish', False, None),
        ]
        container.all.return_value = plugins

        # test
        s = loaded(container, actions)

        # validation
        self.assertEqual(s, HELP % {'plugin': plugins[0].name})
Exemplo n.º 6
0
    def test_loaded(self, actions):
        catalog = {
            Dog.__name__: Class(
                Dog,
                methods={
                    n: Method(m) for n, m in inspection.methods(Dog)
                }
            ),
            'stuff': Module(
                'stuff',
                functions={
                    bar1.__name__: Function(bar1),
                    bar2.__name__: Function(bar2),
                    bar3.__name__: Function(bar3),
                }
            )
        }
        plugins = [
            Plugin('animals', True, Mock(catalog=catalog)),
            Plugin('fish', False, None),
        ]

        container = Mock()
        container.all.return_value = plugins

        actions.collated.return_value = [
            Action('report', None, hours=24),
            Action('reboot', None, minutes=10)
        ]

        # test
        actual = loaded(container, actions)

        # validation
        expected = HELP % {'plugin': plugins[0].name}
        self.assertEqual(expected, actual)