Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aucampia committed May 28, 2022
1 parent 9c023aa commit 9dcbb51
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 35 deletions.
67 changes: 39 additions & 28 deletions test/test_w3c_spec/test_sparql_w3c_new.py
Expand Up @@ -159,8 +159,11 @@ def load_into(self, manifest: Manifest, dataset: Dataset) -> None:
"public_id = %s - graph = %s\n%s", public_id, graph_path, graph_text
)
dataset.parse(
data=graph_text, publicID=graph_local, format=guess_format(graph_path)
data=graph_text, publicID=self.graph_id, format=guess_format(graph_path)
)
# dataset.parse(
# data=graph_text, publicID=graph_local, format=guess_format(graph_path)
# )


@dataclass
Expand Down Expand Up @@ -292,7 +295,13 @@ def load_result(cls, uri_mapper: URIMapper, result_uri: str) -> Tuple[Result, st
format = guess_format(f"{result_path}")
assert format is not None
graph.parse(data=result_text, format=format, publicID=result_uri)
return RDFResultParser().parse(graph), format
result = RDFResultParser().parse(graph)
if logger.isEnabledFor(logging.DEBUG):
logging.debug(
"result.bindings = \n%s",
pprint.pformat(result.bindings, indent=2, width=80),
)
return result, format

# if ResultTypeTrait.GRAPH_RESULT in ResultType.ASK.info.traits:
# RDFResultParser
Expand Down Expand Up @@ -380,8 +389,17 @@ def check_query(entry: SPARQLEntry) -> None:
for graph_data in entry.action_graph_data:
graph_data.load_into(entry.manifest, dataset)

logging.debug("running query, base=%s", urljoin(query_local, "."))
result = dataset.query(query_text, base=urljoin(query_local, "."))
# query_base = urljoin(query_local, ".")
query_base = urljoin(entry.query, ".")
logging.debug("query_base=%s", query_base)
result = dataset.query(query_text, base=query_base)

if logger.isEnabledFor(logging.DEBUG):
# logging.debug("result.bindings = %s", result.bindings)
logging.debug(
"dataset = \n%s",
dataset.serialize(format="trig"),
)

# logging.debug(
# "result.bindings = \n%s", expected_result.serialize().decode("utf-8")
Expand Down Expand Up @@ -450,7 +468,6 @@ def check_query(entry: SPARQLEntry) -> None:
MF.ServiceDescriptionTest,
MF.ProtocolTest,
}
SKIP_URI_PREFIXES = {}


def check_entry(entry: SPARQLEntry) -> None:
Expand Down Expand Up @@ -619,22 +636,12 @@ def check_entry(entry: SPARQLEntry) -> None:
f"{SQ11_REMOTE_BASE_IRI}functions/manifest#strdt03": pytest.mark.xfail(
reason="unclear"
),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}aggregates/manifest#agg-err-01": pytest.mark.xfail(
reason="Error in AVG should return no binding but it does."
),
f"{SQ10_REMOTE_BASE_IRI}basic/manifest#term-6": pytest.mark.xfail(
reason="query misinterpreted."
),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ11_REMOTE_BASE_IRI}entailment/manifest#paper-sparqldl-Q4": pytest.mark.xfail(
reason="entailment not implemented"
),
Expand All @@ -644,18 +651,6 @@ def check_entry(entry: SPARQLEntry) -> None:
f"{SQ11_REMOTE_BASE_IRI}entailment/manifest#parent8": pytest.mark.xfail(
reason="entailment not implemented"
),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(
reason="entailment not implemented"
),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(
reason="entailment not implemented"
),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(
reason="entailment not implemented"
),
f"{SQ11_REMOTE_BASE_IRI}": pytest.mark.xfail(
reason="entailment not implemented"
),
f"{SQ11_REMOTE_BASE_IRI}entailment/manifest#paper-sparqldl-Q1": pytest.mark.xfail(
reason="entailment not implemented"
),
Expand Down Expand Up @@ -779,9 +774,25 @@ def check_entry(entry: SPARQLEntry) -> None:
f"{SQ10_REMOTE_BASE_IRI}open-world/manifest#date-1": pytest.mark.xfail(
reason="RDFLib has more rows than it should have."
),
f"{SQ10_REMOTE_BASE_IRI}open-world/manifest#date-2": pytest.mark.xfail(
reason="RDFLib result has one too few rows."
),
f"{SQ10_REMOTE_BASE_IRI}optional-filter/manifest#dawg-optional-filter-005-simplified": pytest.mark.xfail(
reason="one row is missing a column"
),
f"{SQ10_REMOTE_BASE_IRI}expr-builtin/manifest#dawg-datatype-2": pytest.mark.xfail(
reason="additional row in output"
),
f"{SQ10_REMOTE_BASE_IRI}reduced/manifest#reduced-2": pytest.mark.xfail(
reason="fails 2/3rds or the time"
),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
f"{SQ10_REMOTE_BASE_IRI}": pytest.mark.xfail(reason="..."),
},
markers=(
lambda entry: pytest.mark.skip(reason="test not supported")
lambda entry: pytest.mark.skip(reason="tester not implemented")
if entry.type in SKIP_TYPES
else None,
),
Expand Down
9 changes: 7 additions & 2 deletions test/utils/result.py
Expand Up @@ -269,8 +269,13 @@ def assert_bindings_sequences_equal(
logging.debug("common = \n%s", pprint.pformat(common, indent=1, width=80))
logging.debug("lhs_only = \n%s", pprint.pformat(lhs_only, indent=1, width=80))
logging.debug("rhs_only = \n%s", pprint.pformat(rhs_only, indent=1, width=80))
assert lhs_only == []
assert rhs_only == []
if invert:
assert lhs_only != [] or rhs_only != []
assert (len(common) != len(lhs)) or (len(common) != len(rhs))
else:
assert lhs_only == []
assert rhs_only == []
assert (len(common) == len(lhs)) and (len(common) == len(rhs))


# def _comparable_bindings(
Expand Down
18 changes: 13 additions & 5 deletions test/utils/test/test_result.py
@@ -1,6 +1,10 @@
import logging
from contextlib import ExitStack
from test.utils.result import BindingsSequenceType, comparable_bindings
from test.utils.result import (
BindingsSequenceType,
assert_bindings_sequences_equal,
comparable_bindings,
)
from typing import Type, Union

import pytest
Expand Down Expand Up @@ -237,14 +241,18 @@ def test_bindings_equal(
with ExitStack() as xstack:
if isinstance(expected_result, type) and issubclass(expected_result, Exception):
catcher = xstack.enter_context(pytest.raises(expected_result))
if expected_result is True:
assert comparable_bindings(lhs) == comparable_bindings(rhs)
elif expected_result is False:
assert comparable_bindings(lhs) != comparable_bindings(rhs)
assert_bindings_sequences_equal(lhs, rhs, not expected_result)
# if expected_result is True:
# assert comparable_bindings(lhs) == comparable_bindings(rhs)
# elif expected_result is False:
# assert comparable_bindings(lhs) != comparable_bindings(rhs)
# result, msg = bindings_equal(lhs, rhs)
# logging.debug("result = %s, msg = %s", result, msg)
if catcher is not None:
assert isinstance(catcher.value, Exception)
# else:
# assert isinstance(expected_result, bool)
# assert expected_result == result


# def test_comparable_node() ->

0 comments on commit 9dcbb51

Please sign in to comment.