def METHOD_NAME(self, request):
    discrepancies = []
    def add_discrepancy(name, expected, actual):
        discrepancies.append("{}:\n\t expected: {}\n\t   actual: {}".format(name, expected, actual))
    if self.base_url and not request.url.startswith(self.base_url):
        add_discrepancy("base url", self.base_url, request.url)
    if self.url and self.url != request.url:
        add_discrepancy("url", self.url, request.url)
    if self.url_substring and self.url_substring not in request.url:
        add_discrepancy("url substring", self.url_substring, request.url)
    parsed = urlparse(request.url)
    if self.authority and parsed.netloc != self.authority:
        add_discrepancy("authority", self.authority, parsed.netloc)
    if self.method and request.method != self.method:
        add_discrepancy("method", self.method, request.method)
    for param, expected_value in self.required_params.items():
        actual_value = request.query.get(param)
        if actual_value != expected_value:
            add_discrepancy(param, expected_value, actual_value)
    for header, expected_value in self.required_headers.items():
        actual_value = request.headers.get(header)
        # UserAgentPolicy appends the value of $AZURE_HTTP_USER_AGENT, which is set in
        # pipelines, so we accept a user agent which merely contains the expected value
        if header.lower() == "user-agent":
            if expected_value not in actual_value:
                add_discrepancy("user-agent", "contains " + expected_value, actual_value)
        elif actual_value != expected_value:
            add_discrepancy(header, expected_value, actual_value)
    for field, expected_value in self.required_data.items():
        actual_value = request.body.get(field)
        if actual_value != expected_value:
            add_discrepancy("form field", expected_value, actual_value)
    assert not discrepancies, "Unexpected request\n\t" + "\n\t".join(discrepancies)