def on_get(self, req, resp): """Execution of the GET graph statistics request.""" fuseki = GraphStore() resp.data = json.dumps(fuseki._graph_statistics(), indent=1, sort_keys=True) resp.content_type = 'application/json' resp.status = falcon.HTTP_200 app_logger.info( 'Finished operations on /graph/statistics GET Request.')
def test_graph_stats(self): """Test graph list on graph endpoint.""" list_query = quote( "select ?g (count(*) as ?count) {graph ?g {?s ?p ?o}} group by ?g") with open('tests/resources/graph_stats_request.json') as datafile1: graph_data = json.load(datafile1) with open('tests/resources/graph_stats_response.json') as datafile2: graph_stats = json.load(datafile2) with open('tests/resources/graph_list_request.json') as datafile3: graph_list = json.load(datafile3) responses.add(responses.GET, "{0}stats/{1}".format(self.server_address, "ds"), json=graph_data, status=200) responses.add(responses.GET, "{0}/sparql?query={1}".format(self.request_address, list_query), json=graph_list, status=200) fuseki = GraphStore() result = fuseki._graph_statistics() assert (result == graph_stats)
def test_graph_stats_bad(self): """Test ConnectionError graph stats on graph endpoint.""" fuseki = GraphStore() with self.assertRaises(ConnectionError): fuseki._graph_statistics()