From 145a23aca935b77e53dcb6f1c7d7635291cef046 Mon Sep 17 00:00:00 2001 From: Johan Schreurs Date: Thu, 13 Apr 2023 16:04:21 +0200 Subject: [PATCH] test: Improve integration test based on code review Simplified and removed some unnecessary things from conftest.py. Better environment variable name: OPENEO_BACKEND_URL and default backend in run-integration-tests.sh . Issue #63 --- README.md | 4 +-- integration-tests/conftest.py | 43 ++++----------------------- integration-tests/test_integration.py | 3 +- scripts/run-integration-tests.sh | 2 +- 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 8b4308dc..742f2d68 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,12 @@ To make it easier to run the integration test suite against the _default_ backen To run the integration test suite against any other OpenEO backend: -- first, specify the backend base URL in environment variable `ENDPOINT` , +- first, specify the backend base URL in environment variable `OPENEO_BACKEND_URL` , - then run the tests with `pytest integration-tests/` For example: - export ENDPOINT=http://localhost:8080/ + export OPENEO_BACKEND_URL=http://localhost:8080/ pytest integration-tests/ diff --git a/integration-tests/conftest.py b/integration-tests/conftest.py index 5d115735..35fe78bb 100644 --- a/integration-tests/conftest.py +++ b/integration-tests/conftest.py @@ -3,33 +3,19 @@ import openeo import pytest import requests -from openeo.capabilities import ComparableVersion -def get_openeo_base_url(version: str = "1.1.0"): +@pytest.fixture +def api_base_url(): try: - endpoint = os.environ["ENDPOINT"].rstrip("/") + endpoint = os.environ["OPENEO_BACKEND_URL"] except Exception: raise RuntimeError( - "Environment variable 'ENDPOINT' should be set" + "Environment variable 'OPENEO_BACKEND_URL' should be set" " with URL pointing to OpenEO backend to test against" - " (e.g. 'http://localhost:8080/' or 'http://openeo-dev.vgt.vito.be/')" + " (e.g. 'http://localhost:8080/openeo/1.1.0' or 'http://openeo-dev.vgt.vito.be/openeo/1.1.0')" ) - return "{e}/openeo/{v}".format(e=endpoint.rstrip("/"), v=version) - - -@pytest.fixture( - params=[ - "1.1.0", - ] -) -def api_version(request) -> ComparableVersion: - return ComparableVersion(request.param) - - -@pytest.fixture -def api_base_url(api_version): - return get_openeo_base_url(str(api_version)) + return endpoint.rstrip("/") @pytest.fixture @@ -47,20 +33,3 @@ def requests_session(request) -> requests.Session: @pytest.fixture def connection(api_base_url, requests_session) -> openeo.Connection: return openeo.connect(api_base_url, session=requests_session) - - -@pytest.fixture -def connection100(requests_session) -> openeo.Connection: - return openeo.connect(get_openeo_base_url("1.0.0"), session=requests_session) - - -# TODO: real authentication? -TEST_USER = "jenkins" -TEST_PASSWORD = TEST_USER + "123" - - -@pytest.fixture -def auth_connection(connection) -> openeo.Connection: - """Connection fixture to a backend of given version with some image collections.""" - connection.authenticate_basic(TEST_USER, TEST_PASSWORD) - return connection diff --git a/integration-tests/test_integration.py b/integration-tests/test_integration.py index f216c4e1..5c8fad3e 100644 --- a/integration-tests/test_integration.py +++ b/integration-tests/test_integration.py @@ -1,13 +1,12 @@ import logging import openeo -import pytest _log = logging.getLogger(__name__) def test_openeo_cloud_root_return_sensible_response(connection: openeo.Connection): - """Check that ${ENDPOINT}/openeo/1.0/ returns something sensible.""" + """Check that ${OPENEO_BACKEND_URL}/ returns something sensible.""" path = "/" response = connection.get(path) diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index 4fa8401e..dff98c3c 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -1,2 +1,2 @@ -export ENDPOINT=https://openeocloud.vito.be +export OPENEO_BACKEND_URL=https://openeo.cloud/ pytest -ra -vv integration-tests/