def test_double_quotes_uri(self): test_uris = [ 'http://dbpedia.org/resource/O"Reilly_Media', 'http://dbpedia.org/resource/O"Reilly"_Media' ] for uri in test_uris: knowledge.name_for_uri(uri) knowledge.summary_for_uri(uri) knowledge.coordinates_for_uri(uri) knowledge.image_for_uri(uri) knowledge.aliases_for_uri(uri)
def test_single_quotes_uri(self): test_uris = [ "http://dbpedia.org/resource/O'Reilly_Media", "http://dbpedia.org/resource/O'Reilly'_Media", ] for uri in test_uris: knowledge.name_for_uri(uri) knowledge.summary_for_uri(uri) knowledge.coordinates_for_uri(uri) knowledge.image_for_uri(uri) knowledge.aliases_for_uri(uri)
def test_coordinates_for_uri(self): self.mock_resp.read.return_value = b'{\n "head": {\n "vars": [ "lat" , "long" ]\n } ,\n "results": {\n "bindings": [\n {\n "lat": { "datatype": "http://www.w3.org/2001/XMLSchema#float" , "type": "typed-literal" , "value": "39.90638888888889" } ,\n "long": { "datatype": "http://www.w3.org/2001/XMLSchema#float" , "type": "typed-literal" , "value": "116.37972222222223" }\n }\n ]\n }\n}\n' coordinates = knowledge.coordinates_for_uri( 'http://dbpedia.org/resource/Beijing') self.assertEqual(coordinates, { 'lat': '39.90638888888889', 'long': '116.37972222222223' })
def test_coordinates_for_uri(self): self.mock_resp.read.return_value = b'{\n "head": {\n "vars": [ "lat" , "long" ]\n } ,\n "results": {\n "bindings": [\n {\n "lat": { "datatype": "http://www.w3.org/2001/XMLSchema#float" , "type": "typed-literal" , "value": "39.90638888888889" } ,\n "long": { "datatype": "http://www.w3.org/2001/XMLSchema#float" , "type": "typed-literal" , "value": "116.37972222222223" }\n }\n ]\n }\n}\n' coordinates = knowledge.coordinates_for_uri('http://dbpedia.org/resource/Beijing') self.assertEqual(coordinates, {'lat': '39.90638888888889', 'long': '116.37972222222223'})