How to use the pactman.verifier.parse_header.parse_header function in pactman

To help you get started, we’ve selected a few pactman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reecetech / pactman / pactman / verifier / verify.py View on Github external
def compare_header(self, data, spec, path):
        parsed_data = sorted(parse_header(data))
        parsed_spec = sorted(parse_header(spec))
        log.debug(f"compare_header data={parsed_data} spec={parsed_spec}")
        if parsed_data == parsed_spec:
            return True

        if path[1].lower() != "content-type":
            return self.result.fail(
                f"{self.interaction_name} header {path[1]} value {data!r} does not match "
                f"expected {spec!r}"
            )
        # there's a specific caveat to header matching that says that if the headers don't match and they're a
        # Content-Type and an encoding present in one and not the other, then that's OK

        # first, confirm the non-charset parts match
        data_without_charset = [part for part in parsed_data if not part.has_param("charset")]
        spec_without_charset = [part for part in parsed_spec if not part.has_param("charset")]
        if data_without_charset != spec_without_charset:
github reecetech / pactman / pactman / verifier / verify.py View on Github external
def compare_header(self, data, spec, path):
        parsed_data = sorted(parse_header(data))
        parsed_spec = sorted(parse_header(spec))
        log.debug(f"compare_header data={parsed_data} spec={parsed_spec}")
        if parsed_data == parsed_spec:
            return True

        if path[1].lower() != "content-type":
            return self.result.fail(
                f"{self.interaction_name} header {path[1]} value {data!r} does not match "
                f"expected {spec!r}"
            )
        # there's a specific caveat to header matching that says that if the headers don't match and they're a
        # Content-Type and an encoding present in one and not the other, then that's OK

        # first, confirm the non-charset parts match
        data_without_charset = [part for part in parsed_data if not part.has_param("charset")]
        spec_without_charset = [part for part in parsed_spec if not part.has_param("charset")]