def test_is_expected_content_type_json_non_lowercase(): """Per RFC 2045, media type matching is case insensitive.""" expected_ct = "application/json" response_ct = "Application/JSON" assert is_expected_content_type( response_content_type=response_ct, expected_content_type=expected_ct )
def test_is_expected_content_type_non_json_not_match(): expected_ct = 'application/json' response_ct = 'text/plain' assert not is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_non_json_match_exact(): expected_ct = 'text/javascript' response_ct = 'text/javascript' assert is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_json_match_partially(): expected_ct = 'application/json' response_ct = 'application/alto-costmap+json' # mime-type from rfc7285 assert is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_json_match_exact(): expected_ct = 'application/json' response_ct = 'application/json' assert is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_json_trailing_chars(): expected_ct = "application/json" response_ct = "application/json-seq" assert not is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_non_application_json_private_suffix(): expected_ct = "application/json" response_ct = "x-foo/bar+json" # rfc 6839 assert is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)
def test_is_expected_content_type_non_application_json_suffix(): expected_ct = "application/json" response_ct = "model/gltf+json" # rfc 6839 assert is_expected_content_type(response_content_type=response_ct, expected_content_type=expected_ct)