Skip to content

Commit

Permalink
test: add more accommodation for DBpedia issues (#2543)
Browse files Browse the repository at this point in the history
Some further tests failed due to DBPedia issues, this change adds
further accommodation for this.

Test that use external services should be avoided if possible and should
be replaced with the HTTP mocking facilities of the test framework.
  • Loading branch information
aucampia authored Aug 25, 2023
1 parent 35e5543 commit 5b02406
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions test/test_sparql/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def test_service():
<http://www.w3.org/2000/01/rdf-schema#comment> ?dbpComment .
} } } limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
print(results.vars)
print(results.bindings)
assert len(results) == 2
Expand All @@ -52,7 +55,10 @@ def test_service_with_bind():
<http://purl.org/dc/terms/subject> ?subject .
} } } limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand Down Expand Up @@ -88,7 +94,10 @@ def test_service_with_bound_solutions():
}
LIMIT 2
"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand All @@ -111,7 +120,10 @@ def test_service_with_values():
<http://purl.org/dc/terms/subject> ?subject .
} } } limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand All @@ -128,7 +140,10 @@ def test_service_with_implicit_select():
{
values (?s ?p ?o) {(<http://example.org/a> <http://example.org/b> 1) (<http://example.org/a> <http://example.org/b> 2)}
}} limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand All @@ -146,7 +161,10 @@ def test_service_with_implicit_select_and_prefix():
{
values (?s ?p ?o) {(ex:a ex:b 1) (<http://example.org/a> <http://example.org/b> 2)}
}} limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand All @@ -164,7 +182,10 @@ def test_service_with_implicit_select_and_base():
{
values (?s ?p ?o) {(<a> <b> 1) (<a> <b> 2)}
}} limit 2"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 2

for r in results:
Expand Down Expand Up @@ -212,7 +233,10 @@ def test_simple_not_null():
VALUES (?s ?p ?o) {(<http://example.org/a> <http://example.org/b> "c")}
}
}"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")
assert results.bindings[0].get(Variable("o")) == Literal("c")


Expand Down Expand Up @@ -240,7 +264,10 @@ def test_service_node_types():
}
FILTER( ?o IN (<http://example.org/URI>, "Simple Literal", "String Literal"^^xsd:string, "String Language"@en) )
}"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except (RemoteDisconnected, IncompleteRead):
pytest.skip("this test uses dbpedia which is down sometimes")

expected = freeze_bindings(
[
Expand Down

0 comments on commit 5b02406

Please sign in to comment.