def test_default_actions(): daemon = Daemon() assert daemon.list_actions() == ['start', 'stop', 'restart', 'status'] assert daemon.get_action('start') == daemon.start assert daemon.get_action('stop') == daemon.stop assert daemon.get_action('restart') == daemon.restart assert daemon.get_action('status') == daemon.status with pytest.raises(DaemonError): daemon.get_action('banana')
def get_command(self, ctx, name): """Get a callable command object.""" if name not in Daemon.list_actions(): return None # Assign the daemon worker as the partial of the group callback # with the parameters received (these are the parameters of the # group, not of the command). assert self.group_cb self.daemon.worker = partial(self.group_cb, **ctx.params) return self.commands[name]