From 25986fd9b18f1499a4580af852b24fb81ac2a7d8 Mon Sep 17 00:00:00 2001 From: Colton Loftus <70598503+C-Loftus@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:05:07 -0500 Subject: [PATCH] sparql link test working --- userCode/test/test_e2e.py | 53 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/userCode/test/test_e2e.py b/userCode/test/test_e2e.py index 9bccecec..dd3542f1 100644 --- a/userCode/test/test_e2e.py +++ b/userCode/test/test_e2e.py @@ -12,6 +12,29 @@ from userCode.test.lib import execute_sparql +def assert_data_is_linked_in_graph(): + """Check that a mainstem is associated with a monitoring location in the graph""" + query = """ + select * where { + ?o . + } limit 100 + """ + + resultDict = execute_sparql(query) + assert "FLORIDA FARMERS CANAL" in resultDict["o"] + + query = """ + PREFIX hyf: + + select * where { + ?monitoringLocation hyf:referencedPosition/hyf:HY_IndirectPosition/hyf:linearElement . + } limit 100 + """ + resultDict = execute_sparql(query) + # make sure that the florida canal monitoring location is on the florida river mainstem + assert "https://geoconnex.us/ref/gages/1190185" in resultDict["monitoringLocation"] + + def test_materialize_ref_hu02(): instance = DagsterInstance.ephemeral() assets = load_assets_from_modules([main]) @@ -45,37 +68,21 @@ def test_materialize_ref_hu02(): query = """ select * where { - ?s ?p . - } limit 100 - """ - resultDict = execute_sparql(query) - assert len(resultDict) > 0 - assert "https://geoconnex.us/ref/mainstems/65655" in resultDict["s"] - - query = """ - select * where { - ?o . + ?o . } limit 100 """ resultDict = execute_sparql(query) - assert len(resultDict) > 0 - assert "Junction Creek" in resultDict["o"] + assert "Florida River" in resultDict["o"], ( + "The Florida River Mainstem was not found in the graph" + ) result = resolved_job.execute_in_process( - instance=instance, partition_key="ref_dams_dams__0" + instance=instance, partition_key="cdss_co_gages__0" ) - assert result.success, "Job execution failed for partition 'ref_dams_dams__0'" + assert result.success, "Job execution failed for partition 'cdss_co_gages__0'" - query = """ - select * where { - ?o . - } limit 100 - """ - - resultDict = execute_sparql(query) - assert len(resultDict) > 0 - assert "Upper Railroad" in resultDict["o"] + assert_data_is_linked_in_graph() def test_dynamic_partitions():