Skip to content

Commit

Permalink
Working on RDFLib#955 BIND test now fails as it should. Looks like al…
Browse files Browse the repository at this point in the history
…gebra changes might still be required
  • Loading branch information
JervenBolleman committed May 10, 2020
1 parent 34693fd commit ab0a217
Showing 1 changed file with 27 additions and 52 deletions.
79 changes: 27 additions & 52 deletions test/test_sparql_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,32 @@

class SparqlStarTests(unittest.TestCase):

def test_basic_sparql_star_subject(self):
g = Graph()
g.parse(data="""
reif_as_object = """
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
ex:about a ex:reif .
""", format="ttl")
"""
reif_as_subject = """
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
ex:reif a ex:about .
"""

def test_basic_sparql_star_subject(self):
g = Graph()
g.parse(data=self.reif_as_object, format="ttl")
res = g.query('''SELECT * WHERE {<< ?s ?p ?o >> ?p2 ?o2 . }''')

rl = list(res)
Expand All @@ -27,17 +40,7 @@ def test_basic_sparql_star_subject(self):

def test_basic_sparql_star_object(self):
g = Graph()
g.parse(data="""
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
ex:about a ex:reif .
""", format="ttl")
g.parse(data=self.reif_as_object, format="ttl")
res = g.query('''SELECT * WHERE {
?s ?p << ?s2 ?p2 ?o2 >> .
}''')
Expand All @@ -47,17 +50,7 @@ def test_basic_sparql_star_object(self):

def test_basic_sparql(self):
g = Graph()
g.parse(data="""
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
ex:about a ex:reif .
""", format="ttl")
g.parse(data=self.reif_as_object, format="ttl")
res = g.query('''PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
?s ?p ?o .
Expand All @@ -70,24 +63,16 @@ def test_basic_sparql(self):
rl = list(res)
self.assertEqual(1 , len(rl))

@staticmethod
def test_bind_sparql_star():
def test_bind_sparql_star(self):
g = Graph()
g.parse(data=self.reif_as_subject, format="ttl")
res = g.query('''SELECT * WHERE { BIND(<< ?s2 ?p2 ?o2 >> AS ?b) }''')
rl = list(res)
self.assertEqual(1, len(rl))

def test_constant_sparql_star_object(self):
g = Graph()
g.parse(data="""
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
ex:reif a ex:about .
""", format="ttl")
g.parse(data=self.reif_as_subject, format="ttl")
res = g.query('''PREFIX ex:<http://example.org/> SELECT * WHERE {
<< ex:subject ex:predicate ?object >> a ex:about .
}''')
Expand All @@ -96,18 +81,7 @@ def test_constant_sparql_star_object(self):

def test_constant_sparql_object(self):
g = Graph()
g.parse(data="""
PREFIX ex:<http://example.org/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
ex:subject ex:predicate ex:object .
ex:reif a rdf:Statement ;
a ex:about ;
rdf:subject ex:subject ;
rdf:predicate ex:predicate ;
rdf:object ex:object .
""", format="ttl")
g.parse(data=self.reif_as_subject, format="ttl")
res = g.query('''PREFIX ex:<http://example.org/> SELECT * WHERE {
ex:subject ex:predicate ?object .
ex:reif a ex:about ;
Expand All @@ -118,5 +92,6 @@ def test_constant_sparql_object(self):
}''')
rl = list(res)
self.assertEqual(1 , len(rl))

if __name__ == '__main__':
unittest.main()

0 comments on commit ab0a217

Please sign in to comment.