Skip to content

Commit

Permalink
test: add skips to accommodate a DBpedia outage
Browse files Browse the repository at this point in the history
DBpedia is failing right now. This change adds narrow skips to the tests
that use it which only trigger for connection related problems, so the
test suite can pass even when DBpedia is down.

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 committed Aug 24, 2023
1 parent cce5dd2 commit 78a6791
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 19 additions & 1 deletion test/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import subprocess
import sys
from pathlib import Path
Expand Down Expand Up @@ -29,4 +30,21 @@ def test_example(example_file: Path) -> None:
# this example requires a berkeleydb installation
pytest.skip("The BerkeleyDB example is not working correctly.")

subprocess.run([sys.executable, f"{example_file}"], check=True)
result = subprocess.run(
[sys.executable, f"{example_file}"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)

logging.debug("result = %s", result)

try:
result.check_returncode()
except subprocess.CalledProcessError:
if (
example_file.stem == "sparqlstore_example"
and "http.client.RemoteDisconnected: Remote end closed connection without response"
in result.stderr.decode("utf-8")
):
pytest.skip("this test uses dbpedia which is down sometimes")
raise
6 changes: 5 additions & 1 deletion test/test_sparql/test_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from http.client import RemoteDisconnected
from test.utils import helper
from test.utils.http import MethodName, MockHTTPResponse
from test.utils.httpservermock import ServedBaseHTTPServerMock
Expand Down Expand Up @@ -181,7 +182,10 @@ def test_service_with_implicit_select_and_allcaps():
?s <http://www.w3.org/2002/07/owl#sameAs> ?sameAs .
}
} LIMIT 3"""
results = helper.query_with_retry(g, q)
try:
results = helper.query_with_retry(g, q)
except RemoteDisconnected:
pytest.skip("this test uses dbpedia which is down sometimes")
assert len(results) == 3


Expand Down

0 comments on commit 78a6791

Please sign in to comment.