コード例 #1
0
ファイル: builtin.py プロジェクト: pombredanne/gofer
 def help(self):
     """
     Show information about loaded plugins.
     :return: Information
     :rtype: str
     """
     return loaded(self.container, Actions())
コード例 #2
0
ファイル: builtin.py プロジェクト: swipswaps/gofer
 def help(self):
     """
     Show information about loaded plugins.
     :return: Information
     :rtype: str
     """
     return loaded(self.container, Actions())
コード例 #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)
コード例 #4
0
ファイル: test_reporting.py プロジェクト: darinlively/gofer
    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})
コード例 #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})
コード例 #6
0
ファイル: test_reporting.py プロジェクト: jortel/gofer
    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)