'Assert that a method was called on a session with JSON.'

def method_called_with(self, method_name, args, kwargs):

    mock_method = getattr(self.session, method_name)
    assert (mock_method.called is True)
    (call_args, call_kwargs) = mock_method.call_args
    data = kwargs.pop('data', None)
    call_data = call_kwargs.pop('data', None)
    if (call_data is None):
        (call_args, call_data) = (call_args[:1], call_args[1])
    if ((not isinstance(data, str)) and call_data):
        call_data = json.loads(call_data)
    assert (args == call_args)
    assert (data == call_data)
    assert (kwargs == call_kwargs)
