def test_binding_with_uri(self): uri_object_dict = { 'o': { 'value': 'http://localhost:8000/resource/dataset/ton-smits-huis', 'type': 'uri' } } obj = RDFModel.get_object_from_sparql_result(uri_object_dict['o']) assert obj is not None assert isinstance(obj, URIRef) assert obj == URIRef(uri_object_dict['o']['value'])
def test_with_language_literal(self): literal_object_dict = { 'o3': { 'value': 'bomen', 'xml:lang': 'nl', 'type': 'literal' } } obj = RDFModel.get_object_from_sparql_result(literal_object_dict) assert obj is not None assert isinstance(obj, Literal) assert obj.language == "nl" assert obj.datatype is None assert obj == Literal( literal_object_dict['o3']['value'], lang="nl" )
def test_binding_with_typed_literal(self): object_dict = { 'o2': { 'value': 'false', 'type': 'typed-literal', 'datatype': 'http://www.w3.org/2001/XMLSchema#boolean' } } obj = RDFModel.get_object_from_sparql_result(object_dict) assert obj is not None assert isinstance(obj, Literal) assert obj.language is None assert obj.datatype is not None assert obj.datatype == URIRef("http://www.w3.org/2001/XMLSchema#boolean") assert obj == Literal( object_dict['o2']['value'], datatype="http://www.w3.org/2001/XMLSchema#boolean" )