def test_query_no_resource(self): with self.assertRaises(ValueError): next( get_sliced_data( "SELECT DISTINCT ?g WHERE {GRAPH ?g {?a ?b ?c}}", fields='acheneID,provenance', ))
def test_query_malformed(self): with self.assertRaises(ValueError): next( get_sliced_data( "this is a terribly wrong query", fields='acheneID,provenance', ))
def test_query_ok(self): graph_pref = settings.TRIPLE_DATABASE['PREFIXES']['data_graph_mapped'] get_virtuoso('master').ingest(self._get_test_file( 'boardgamegeek-games-mapped.nt', 'scheduler'), graph=graph_pref + 'test_graph') results = get_cleaned_sliced_data(query=THE_QUERY, fields='acheneID,provenance', with_header=True) header = next(results) self.assertIsInstance(header, list) self.assertGreater(len(list(results)), 0) results = get_sliced_data(query=THE_QUERY, fields='acheneID,provenance', with_header=False) results = list(results) self.assertIsInstance(results[0], dict)
def test_query_ok(self): graph_pref = settings.TRIPLE_DATABASE['PREFIXES']['data_graph_mapped'] get_virtuoso('master').ingest( self._get_test_file('boardgamegeek-games-mapped.nt', 'scheduler'), graph=graph_pref + 'test_graph' ) results = get_cleaned_sliced_data( query=THE_QUERY, fields='acheneID,provenance', with_header=True ) header = next(results) self.assertIsInstance(header, list) self.assertGreater(len(list(results)), 0) results = get_sliced_data( query=THE_QUERY, fields='acheneID,provenance', with_header=False ) results = list(results) self.assertIsInstance(results[0], dict)
def test_query_no_resource(self): with self.assertRaises(ValueError): next(get_sliced_data( "SELECT DISTINCT ?g WHERE {GRAPH ?g {?a ?b ?c}}", fields='acheneID,provenance', ))
def test_query_malformed(self): with self.assertRaises(ValueError): next(get_sliced_data( "this is a terribly wrong query", fields='acheneID,provenance', ))