Skip to content
Snippets Groups Projects
Commit d4088513 authored by Frank Lange's avatar Frank Lange
Browse files

generalize the way the triplestore is set up in tests

use the "TRIPLESTORE_URL" environment variable instead of detecting the GitLab CI environment
parent 22f6da54
Branches
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ test-job:
- pip install --upgrade -r requirements-dev.txt
- pip freeze
script:
- pytest --cov=project --cov-report html
- TRIPLESTORE_URL="http://fuseki:3030/" pytest --cov=project --cov-report html
artifacts:
paths:
- htmlcov
......
......@@ -20,11 +20,6 @@ def requests_client() -> RequestsClient:
return RequestsClient()
def _is_in_gitlab_ci() -> bool:
gitlab_ci_env_variable = os.environ.get("GITLAB_CI", None)
return gitlab_ci_env_variable and gitlab_ci_env_variable == "true"
@pytest.fixture(scope="session")
def triplestore() -> Generator[None, None, None]:
"""
......@@ -33,16 +28,17 @@ def triplestore() -> Generator[None, None, None]:
This fixture will set up a triplestore and provide its base URL by overriding the Django setting
"DALIA_TRIPLESTORE_BASE_URL".
"""
if _is_in_gitlab_ci():
yield from _triplestore_from_gitlab_service()
triplestore_url_env_variable = os.environ.get("TRIPLESTORE_URL", None)
if triplestore_url_env_variable:
yield from _triplestore_from_custom_url(triplestore_url_env_variable)
else:
yield from _triplestore_from_testcontainer()
# Uses the triplestore provided by GitLab's services (see https://docs.gitlab.com/ee/ci/services/).
def _triplestore_from_gitlab_service() -> Generator[None, None, None]:
def _triplestore_from_custom_url(triplestore_url: str) -> Generator[None, None, None]:
# alter Django settings
settings.DALIA_TRIPLESTORE_BASE_URL = "http://fuseki:3030/"
settings.DALIA_TRIPLESTORE_BASE_URL = triplestore_url
yield
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment