'Run an action and generate responses.
This basically emulates GRRClientWorker.HandleMessage().
Args:
action_cls: The action class to run.
grr_worker: The GRRClientWorker instance to use. If not provided we make
a new one.
Returns:
A list of response protobufs.'

def _GetActionInstance(self, action_cls, grr_worker=None):

    def mock_send_reply(mock_self, reply=None, **kwargs):
        if (reply is None):
            reply = mock_self.out_rdfvalues[0](**kwargs)
        self.results.append(reply)
    if (grr_worker is None):
        grr_worker = worker_mocks.FakeClientWorker()
    action = action_cls(grr_worker=grr_worker)
    action.SendReply = types.MethodType(mock_send_reply, action)
    return action
