File: test_parse_accept.py

package info (click to toggle)
python-rdflib-endpoint 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 264 kB
  • sloc: python: 1,068; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 791 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest

import rdflib_endpoint.sparql_router

accept_cases = [
    ("text/xml", "text/xml"),
    ("text/rdf+xml, text/xml, */*", "text/rdf+xml"),
    ("text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8", "text/html"),
    ("text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=", "text/html"),
    ("text/html;q=0.3, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8", "application/xhtml+xml"),
    (
        'text/turtle;q=0.9;profile="urn:example:profile-1", text/turtle;q=0.7;profile="urn:example:profile-2"',
        "text/turtle",
    ),
]


@pytest.mark.parametrize("accept,expected", accept_cases)
def test_accept_preference(accept, expected):
    pref = rdflib_endpoint.sparql_router.parse_accept_header(accept)
    assert pref[0] == expected