def test_sparql_execute_no_raise_on_error(self): rawresults = _sparqlexecute(u'http://dbpedia.org/sparql', u'''SELECT DISTINCT ?uri WHERE{ ?uri faultyrdf ?uri rdf:type ?type}''') self.assertEqual(rawresults, [])
def test_sparql_execute_raise_on_error(self): with self.assertRaises(RuntimeError): rawresults = _sparqlexecute(u'http://dbpedia.org/sparql', u'''SELECT DISTINCT ?uri WHERE{ ?uri faultyrdf ?uri rdf:type ?type}''', raise_on_error=True)
def test_sparql_execute(self): rawresults = _sparqlexecute(u'http://dbpedia.org/sparql', u'''SELECT DISTINCT ?uri ?designer WHERE { ?uri rdf:type <http://dbpedia.org/ontology/ProgrammingLanguage> ; rdfs:label ?label ; dbpedia-owl:designer ?designer . FILTER(regex(?label, "^Python")) }''') self.assertEqual(rawresults, {'head': {'link': [], 'vars': ['uri', 'designer']}, 'results': { 'bindings': [ {'designer': {'type': 'uri', 'value': 'http://dbpedia.org/resource/Guido_van_Rossum'}, 'uri': {'type': 'uri', 'value': 'http://dbpedia.org/resource/Python_(programming_language)'}}, {'designer': {'type': 'uri', 'value': 'http://dbpedia.org/resource/Guido_van_Rossum'}, 'uri': {'type': 'uri', 'value': 'http://dbpedia.org/resource/Python_for_S60'}}], 'distinct': False, 'ordered': True}})