Skip to content

Commit 92ad509

Browse files
authored
test: fix dbpedia webtests (#3304)
1 parent 3c9d9da commit 92ad509

File tree

1 file changed

+64
-50
lines changed

1 file changed

+64
-50
lines changed

test/test_sparql/test_service.py

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@
1818
@pytest.mark.webtest
1919
def test_service():
2020
g = Graph()
21-
q = """select ?sameAs ?dbpComment
22-
where
23-
{ service <http://DBpedia.org/sparql>
24-
{ select ?dbpHypernym ?dbpComment
25-
where
26-
{
27-
<http://dbpedia.org/resource/John_Lilburne>
28-
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
29-
<http://www.w3.org/2000/01/rdf-schema#comment> ?dbpComment .
30-
31-
} } } limit 2"""
21+
q = """
22+
SELECT ?p ?o
23+
WHERE {
24+
SERVICE <http://DBpedia.org/sparql> {
25+
SELECT ?p ?o
26+
WHERE {
27+
<http://dbpedia.org/resource/John_Lilburne> ?p ?o
28+
}
29+
}
30+
}
31+
LIMIT 2
32+
"""
3233
try:
3334
results = helper.query_with_retry(g, q)
3435
except (RemoteDisconnected, IncompleteRead):
@@ -44,19 +45,23 @@ def test_service():
4445
@pytest.mark.webtest
4546
def test_service_with_bind():
4647
g = Graph()
47-
q = """select ?sameAs ?dbpComment ?subject
48-
where
49-
{ bind (<http://dbpedia.org/resource/Category:1614_births> as ?subject)
50-
service <http://DBpedia.org/sparql>
51-
{ select ?sameAs ?dbpComment ?subject
52-
where
53-
{
54-
<http://dbpedia.org/resource/John_Lilburne>
55-
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
56-
<http://www.w3.org/2000/01/rdf-schema#comment> ?dbpComment ;
57-
<http://purl.org/dc/terms/subject> ?subject .
58-
59-
} } } limit 2"""
48+
q = """
49+
PREFIX dbp: <http://dbpedia.org/property/>
50+
SELECT ?sameAs ?dbpComment ?subject
51+
WHERE {
52+
BIND(<http://dbpedia.org/resource/Category:1614_births> AS ?subject)
53+
SERVICE <http://DBpedia.org/sparql> {
54+
SELECT ?sameAs ?dbpComment ?subject
55+
WHERE {
56+
<http://dbpedia.org/resource/John_Lilburne>
57+
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
58+
dbp:caption ?dbpComment ;
59+
<http://purl.org/dc/terms/subject> ?subject .
60+
}
61+
}
62+
}
63+
LIMIT 2
64+
"""
6065
try:
6166
results = helper.query_with_retry(g, q)
6267
except (RemoteDisconnected, IncompleteRead):
@@ -80,27 +85,30 @@ def test_service_with_bound_solutions():
8085
"""
8186
)
8287
q = """
83-
SELECT ?sameAs ?dbpComment ?subject WHERE {
84-
[]
85-
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
86-
<http://purl.org/dc/terms/subject> ?subject .
87-
88-
SERVICE <http://DBpedia.org/sparql> {
89-
SELECT ?sameAs ?dbpComment ?subject WHERE {
90-
<http://dbpedia.org/resource/John_Lilburne>
88+
PREFIX dbp: <http://dbpedia.org/property/>
89+
SELECT ?sameAs ?dbpComment ?subject
90+
WHERE {
91+
[]
9192
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
92-
<http://www.w3.org/2000/01/rdf-schema#comment> ?dbpComment ;
9393
<http://purl.org/dc/terms/subject> ?subject .
94+
95+
SERVICE <http://DBpedia.org/sparql> {
96+
SELECT ?sameAs ?dbpComment ?subject
97+
WHERE {
98+
<http://dbpedia.org/resource/John_Lilburne>
99+
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
100+
dbp:caption ?dbpComment ;
101+
<http://purl.org/dc/terms/subject> ?subject .
102+
}
103+
}
94104
}
95-
}
96-
}
97-
LIMIT 2
105+
LIMIT 2
98106
"""
99107
try:
100108
results = helper.query_with_retry(g, q)
101109
except (RemoteDisconnected, IncompleteRead):
102110
pytest.skip("this test uses dbpedia which is down sometimes")
103-
assert len(results) == 2
111+
assert len(results) == 1
104112

105113
for r in results:
106114
assert len(r) == 3
@@ -109,19 +117,25 @@ def test_service_with_bound_solutions():
109117
@pytest.mark.webtest
110118
def test_service_with_values():
111119
g = Graph()
112-
q = """select ?sameAs ?dbpComment ?subject
113-
where
114-
{ values (?sameAs ?subject) {(<http://de.dbpedia.org/resource/John_Lilburne> <http://dbpedia.org/resource/Category:1614_births>) (<https://global.dbpedia.org/id/4t6Fk> <http://dbpedia.org/resource/Category:Levellers>)}
115-
service <http://DBpedia.org/sparql>
116-
{ select ?sameAs ?dbpComment ?subject
117-
where
118-
{
119-
<http://dbpedia.org/resource/John_Lilburne>
120-
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
121-
<http://www.w3.org/2000/01/rdf-schema#comment> ?dbpComment ;
122-
<http://purl.org/dc/terms/subject> ?subject .
123-
124-
} } } limit 2"""
120+
q = """
121+
PREFIX dbp: <http://dbpedia.org/property/>
122+
SELECT ?sameAs ?dbpComment ?subject
123+
WHERE {
124+
VALUES (?sameAs ?subject) {
125+
(<http://de.dbpedia.org/resource/John_Lilburne> <http://dbpedia.org/resource/Category:1614_births>) (<https://global.dbpedia.org/id/4t6Fk> <http://dbpedia.org/resource/Category:Levellers>)
126+
}
127+
SERVICE <http://DBpedia.org/sparql> {
128+
SELECT ?sameAs ?dbpComment ?subject
129+
WHERE {
130+
<http://dbpedia.org/resource/John_Lilburne>
131+
<http://www.w3.org/2002/07/owl#sameAs> ?sameAs ;
132+
dbp:caption ?dbpComment ;
133+
<http://purl.org/dc/terms/subject> ?subject .
134+
}
135+
}
136+
}
137+
LIMIT 2
138+
"""
125139
try:
126140
results = helper.query_with_retry(g, q)
127141
except (RemoteDisconnected, IncompleteRead):

0 commit comments

Comments
 (0)