summaryrefslogtreecommitdiff
path: root/test/test_w3c_spec/test_sparql_rdflib.py
blob: 2a278461a82c7e28b7086065610e0aa47547cebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Runs the RDFLib SPARQL test suite.
"""
from test.data import TEST_DATA_DIR
from test.utils import ensure_suffix
from test.utils.dawg_manifest import MarksDictType, params_from_sources
from test.utils.iri import URIMapper
from test.utils.sparql_checker import (
    SKIP_TYPES,
    SPARQLEntry,
    check_entry,
    ctx_configure_rdflib,
)
from typing import Generator

import pytest
from pytest import MonkeyPatch

REMOTE_BASE_IRI = (
    "http://raw.github.com/RDFLib/rdflib/main/test/data/suites/rdflib/sparql/"
)
LOCAL_BASE_DIR = TEST_DATA_DIR / "suites/rdflib/sparql/"
MAPPER = URIMapper.from_mappings(
    (REMOTE_BASE_IRI, ensure_suffix(LOCAL_BASE_DIR.as_uri(), "/")),
)

MARK_DICT: MarksDictType = {
    f"{REMOTE_BASE_IRI}manifest.ttl#test-codepoint-escape-02": pytest.mark.xfail(
        reason="known codepoint escape issue"
    ),
    f"{REMOTE_BASE_IRI}manifest.ttl#test-codepoint-escape-03": pytest.mark.xfail(
        reason="known codepoint escape issue"
    ),
    f"{REMOTE_BASE_IRI}manifest.ttl#test-codepoint-escape-04": pytest.mark.xfail(
        reason="known codepoint escape issue"
    ),
    f"{REMOTE_BASE_IRI}manifest.ttl#test-codepoint-escape-bad": pytest.mark.xfail(
        reason="Parses sucessfully instead of failing."
    ),
}


@pytest.fixture(scope="module", autouse=True)
def configure_rdflib() -> Generator[None, None, None]:
    with ctx_configure_rdflib():
        yield None


@pytest.mark.parametrize(
    ["manifest_entry"],
    params_from_sources(
        MAPPER,
        SPARQLEntry,
        LOCAL_BASE_DIR / "manifest.ttl",
        mark_dict=MARK_DICT,
        markers=(
            lambda entry: pytest.mark.skip(reason="tester not implemented")
            if entry.type in SKIP_TYPES
            else None,
        ),
        report_prefix="rdflib_sparql",
    ),
)
def test_entry_rdflib(monkeypatch: MonkeyPatch, manifest_entry: SPARQLEntry) -> None:
    check_entry(monkeypatch, manifest_entry)