> I didn't mean that we don't need a real Django running; a mock one
> will do. But we need something that responds like a real call to
> avoid the mistake that rvb made.
Ah, okeydoke, then I agree. I think we can dynamically create an amp.AMP
subclass with stub responders that correspond to a subset of amp.Command
calls.
Maybe something like:
def make_stub_amp_thing(*commands):
responders = { "responder_for_%s" % command.name: command.responder(Mock())
for command in commands
}
return type("DynamicAMP", amp.AMP, responders)
The `Client` returned from ClusterService.getClient() needs to be
patched to use call_responder in this way. Or, as ClusterRPCFixture
does, the connections that the client uses need to be patched.
> I didn't mean that we don't need a real Django running; a mock one
> will do. But we need something that responds like a real call to
> avoid the mistake that rvb made.
Ah, okeydoke, then I agree. I think we can dynamically create an amp.AMP
subclass with stub responders that correspond to a subset of amp.Command
calls.
Maybe something like:
def make_stub_ amp_thing( *commands) :
"responder _for_%s" % command.name:
command. responder( Mock())
responders = {
for command in commands
}
return type("DynamicAMP", amp.AMP, responders)
amp = make_stub_ amp_thing( MakeMeASandwich ) responder_ for_MakeMeASand wich.return_ value = "Use sudo"
amp.
call_ responder( amp(), MakeMeASandwich, {
"fillings": ["ketchup", "crisps", "scratchings"],
})
The `Client` returned from ClusterService. getClient( ) needs to be
patched to use call_responder in this way. Or, as ClusterRPCFixture
does, the connections that the client uses need to be patched.