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])
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])
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())
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})
def test_call(self): container = Mock() admin = Admin(container) self.assertEqual(admin, admin())
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)
def test_echo(self): text = 'hello' container = Mock() admin = Admin(container) self.assertEqual(admin.echo(text), text)
def test_hello(self): container = Mock() admin = Admin(container) self.assertEqual(admin.hello(), 'Hello, I am gofer agent')
def test_call(self): admin = Admin() self.assertEqual(admin, admin())
def cancel(self, sn=None, criteria=None): container = Container() admin = Admin(container) return admin.cancel(sn=sn, criteria=criteria)
def show(self): container = Container() admin = Admin(container) return admin.help()
def test_echo(self): text = 'hello' admin = Admin() self.assertEqual(admin.echo(text), text)
def test_hello(self): admin = Admin() self.assertEqual(admin.hello(), 'Hello, I am gofer agent')