Thinking about it, I wonder if this function is doing too much. It might be clearer to have this do the Diameter mocking and return deferred_callback.call_args[0][0], and have the calling functions be explicit about the result they expect (rather than building it in here), and then be responsible for the assertEquals themselves.