Exemple #1
0
 def test_cancel_sn(self, tracker):
     sn = '1234'
     container = Mock()
     admin = Admin(container)
     canceled = admin.cancel(sn=sn)
     tracker.return_value.cancel.assert_called_once_with(sn)
     self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
Exemple #2
0
 def test_cancel_sn(self, tracker):
     sn = '1234'
     container = Mock()
     admin = Admin(container)
     canceled = admin.cancel(sn=sn)
     tracker.return_value.cancel.assert_called_once_with(sn)
     self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
Exemple #3
0
    def test_cancel_criteria(self, tracker, builder):
        sn = '1234'
        name = 'joe'
        criteria = {'eq': name}
        tracker.return_value.find.return_value = [sn]

        # test
        admin = Admin()
        canceled = admin.cancel(criteria=criteria)

        # validation
        builder.return_value.build.assert_called_once_with(criteria)
        tracker.return_value.cancel.assert_called_once_with(sn)
        self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
Exemple #4
0
    def test_cancel_criteria(self, tracker, builder):
        sn = '1234'
        name = 'joe'
        criteria = {'eq': name}
        tracker.return_value.find.return_value = [sn]

        # test
        admin = Admin()
        canceled = admin.cancel(criteria=criteria)

        # validation
        builder.return_value.build.assert_called_once_with(criteria)
        tracker.return_value.cancel.assert_called_once_with(sn)
        self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
Exemple #5
0
 def test_dispatch(self):
     request = Document(routing=['A', 'B'],
                        request={
                            'classname': 'Admin',
                            'method': 'hello',
                            'args': [],
                            'keywords': {}
                        })
     plugin = Mock()
     builtin = Builtin(plugin)
     result = builtin.dispatch(request)
     self.assertEqual(result.retval, Admin().hello())
Exemple #6
0
    def test_help(self, container, actions, is_mod, is_fn):
        is_mod.side_effect = lambda thing: thing == Module
        is_fn.return_value = True
        actions.return_value.collated.return_value = [
            Action('report', dict(hours=24)),
            Action('reboot', dict(minutes=10)),
        ]
        dispatcher = Mock(catalog={
            'admin': Admin,
            'dog': Dog,
            'mod': Module,
        })
        plugins = [
            Plugin('animals', True, dispatcher),
            Plugin('fish', False, None),
        ]
        container.return_value.all.return_value = plugins

        # test
        admin = Admin()
        s = admin.help()

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

        # test
        admin = Admin()
        s = admin.help()

        # validation
        self.assertEqual(s, HELP % {'plugin': plugins[0].name})
Exemple #8
0
 def test_call(self):
     container = Mock()
     admin = Admin(container)
     self.assertEqual(admin, admin())
Exemple #9
0
 def test_help(self, loaded, actions):
     container = Mock()
     admin = Admin(container)
     report = admin.help()
     loaded.assert_called_once_with(container, actions.return_value)
     self.assertEqual(report, loaded.return_value)
Exemple #10
0
 def test_echo(self):
     text = 'hello'
     container = Mock()
     admin = Admin(container)
     self.assertEqual(admin.echo(text), text)
Exemple #11
0
 def test_hello(self):
     container = Mock()
     admin = Admin(container)
     self.assertEqual(admin.hello(), 'Hello, I am gofer agent')
Exemple #12
0
 def test_call(self):
     admin = Admin()
     self.assertEqual(admin, admin())
Exemple #13
0
 def cancel(self, sn=None, criteria=None):
     container = Container()
     admin = Admin(container)
     return admin.cancel(sn=sn, criteria=criteria)
Exemple #14
0
 def show(self):
     container = Container()
     admin = Admin(container)
     return admin.help()
Exemple #15
0
 def test_help(self, loaded, actions):
     container = Mock()
     admin = Admin(container)
     report = admin.help()
     loaded.assert_called_once_with(container, actions.return_value)
     self.assertEqual(report, loaded.return_value)
Exemple #16
0
 def test_echo(self):
     text = 'hello'
     container = Mock()
     admin = Admin(container)
     self.assertEqual(admin.echo(text), text)
Exemple #17
0
 def test_echo(self):
     text = 'hello'
     admin = Admin()
     self.assertEqual(admin.echo(text), text)
Exemple #18
0
 def show(self):
     container = Container()
     admin = Admin(container)
     return admin.help()
Exemple #19
0
 def test_echo(self):
     text = 'hello'
     admin = Admin()
     self.assertEqual(admin.echo(text), text)
Exemple #20
0
 def test_hello(self):
     admin = Admin()
     self.assertEqual(admin.hello(), 'Hello, I am gofer agent')
Exemple #21
0
 def test_hello(self):
     admin = Admin()
     self.assertEqual(admin.hello(), 'Hello, I am gofer agent')
Exemple #22
0
 def cancel(self, sn=None, criteria=None):
     container = Container()
     admin = Admin(container)
     return admin.cancel(sn=sn, criteria=criteria)
Exemple #23
0
 def test_hello(self):
     container = Mock()
     admin = Admin(container)
     self.assertEqual(admin.hello(), 'Hello, I am gofer agent')