def test_graph_sparql_bad(self): """Test ConnectionError SPARQL on graph endpoint.""" list_query = quote( "select ?g (count(*) as ?count) {graph ?g {?s ?p ?o}} group by ?g") fuseki = GraphStore() with self.assertRaises(URLError): fuseki._graph_sparql("default", list_query)
def on_post(self, req, resp, parsed): """Execution of the POST SPARQL query request.""" fuseki = GraphStore() data = fuseki._graph_sparql(parsed['namedGraph'], parsed['query']) resp.data = str(data) resp.content_type = 'application/xml' # for now just this type resp.status = falcon.HTTP_200 app_logger.info('Finished operations on /graph/query POST Request.')
def test_graph_sparql(self): """Test update graph.""" with open('tests/resources/graph_sparql.xml') as datafile: graph_data = datafile.read() list_query = "select ?g (count(*) as ?count) {graph ?g {?s ?p ?o}} group by ?g" url = "http://data.hulib.helsinki.fi/attx/strategy" request_url = "{0}/query?default-graph-uri=%s&query={1}&output=xml&results=xml&format=xml".format( self.request_address, url, list_query) httpretty.register_uri(httpretty.GET, request_url, graph_data, status=200, content_type="application/sparql-results+xml") fuseki = GraphStore() result = fuseki._graph_sparql(url, list_query) assert (result == graph_data) httpretty.disable() httpretty.reset()