'Issue an HTTP request and make an assertion about the response code.
:param bytes method: The HTTP method to use in the request.
:param bytes path: The resource path to use in the request.
:param dict request_body: A JSON-encodable object to encode (as JSON)
into the request body.  Or ``None`` for no request body.
:param int expected_code: The status code expected in the response.
:param additional_headers: A mapping, additional HTTP headers to send.
:return: A ``Deferred`` that will fire when the response has been
received.  It will fire with a failure if the status code is
not what was expected.  Otherwise it will fire with an
``IResponse`` provider representing the response.'

def assertResponseCode(self, method, path, request_body, expected_code, additional_headers=pmap()):

    if (request_body is None):
        headers = {}
        body_producer = None
    else:
        headers = {'content-type': ['application/json']}
        body_producer = FileBodyProducer(BytesIO(dumps(request_body)))
    headers.update(additional_headers)
    headers = Headers(headers)
    requesting = self.agent.request(method, path, headers, body_producer)
    def check_code(response):
        self.assertEqual(expected_code, response.code)
        return response
    requesting.addCallback(check_code)
    return requesting
