diff --git a/test/test_w3c_spec/test_sparql_w3c_new.py b/test/test_w3c_spec/test_sparql_w3c_new.py index b501e4f3f..ca65dfe07 100644 --- a/test/test_w3c_spec/test_sparql_w3c_new.py +++ b/test/test_w3c_spec/test_sparql_w3c_new.py @@ -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 @@ -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 @@ -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") @@ -450,7 +468,6 @@ def check_query(entry: SPARQLEntry) -> None: MF.ServiceDescriptionTest, MF.ProtocolTest, } -SKIP_URI_PREFIXES = {} def check_entry(entry: SPARQLEntry) -> None: @@ -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" ), @@ -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" ), @@ -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, ), diff --git a/test/utils/result.py b/test/utils/result.py index 3034956db..b2c5afd19 100644 --- a/test/utils/result.py +++ b/test/utils/result.py @@ -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( diff --git a/test/utils/test/test_result.py b/test/utils/test/test_result.py index 3ca4dba0c..1afdb85b0 100644 --- a/test/utils/test/test_result.py +++ b/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 @@ -237,10 +241,11 @@ 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: @@ -248,3 +253,6 @@ def test_bindings_equal( # else: # assert isinstance(expected_result, bool) # assert expected_result == result + + +# def test_comparable_node() ->