From 4e4e1a4c68017259dd6ff996dc94b1b0faea4fba Mon Sep 17 00:00:00 2001 From: Sebastian Tramp Date: Tue, 8 Sep 2026 15:19:55 +0200 Subject: [PATCH] tests: fail loudly when the result graph is gone _get_triple_count treated a graph which is not in the graph list as a graph with zero triples. When the deployment loses the result graph during a validation - which happens intermittently, reproducibly, and is not a plugin problem - the test reported it as "assert 0 == 16", an assertion about numbers which says nothing about what actually went wrong. The helper now fails with the graph IRI instead, and the pre-condition of test_safe_as_graph, which is what the zero was really there for, is written as the membership check it always was. The message on the first count assertion said "result graph should be empty" while asserting the opposite. No changelog entry: nothing here changes what a user of the plugin sees. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01SxhW9xhADjcpzFezfXBBDk --- tests/test_validate_graph.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_validate_graph.py b/tests/test_validate_graph.py index 29698cb..492f883 100644 --- a/tests/test_validate_graph.py +++ b/tests/test_validate_graph.py @@ -38,10 +38,16 @@ def get_client() -> Client: def _get_triple_count(graph: str) -> int: - """Export a graph as n-triples and count the lines""" + """Export a graph as n-triples and count the lines + + A graph which is not there fails the test instead of counting as empty. The two + are different findings: a validation which writes no result is a plugin problem, + while a result graph vanishing from the deployment is not, and reporting the + second as a count of zero hides it behind an assertion about numbers. + """ client = get_client() if graph not in client.graphs: - return 0 + pytest.fail(f"Graph <{graph}> does not exist in the deployment") with TemporaryDirectory() as temp_dir: path = Path(temp_dir) / "graph.nt" client.graphs.export_item(key=graph, path=path, replace=True, configuration=N_TRIPLES) @@ -146,10 +152,10 @@ def test_safe_as_graph(test_setup: TestSetup) -> None: result_graph=_.result_graph, clear_result_graph=False, ) - assert _get_triple_count(_.result_graph) == 0 + assert _.result_graph not in get_client().graphs, "result graph should not exist yet" task.execute(context=TestExecutionContext(), inputs=[]) result_graph_triples = _get_triple_count(_.result_graph) - assert result_graph_triples > 0, "result graph should be empty" + assert result_graph_triples > 0, "result graph should hold a result set" task.execute(context=TestExecutionContext(), inputs=[]) assert _get_triple_count(_.result_graph) == result_graph_triples * 2, ( "result graph should have two equal result sets"