Skip to content

Commit

Permalink
test: Improve integration test based on code review
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JohanKJSchreurs committed Apr 13, 2023
1 parent 452fa7f commit 145a23a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/


Expand Down
43 changes: 6 additions & 37 deletions integration-tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 1 addition & 2 deletions integration-tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export ENDPOINT=https://openeocloud.vito.be
export OPENEO_BACKEND_URL=https://openeo.cloud/
pytest -ra -vv integration-tests/

0 comments on commit 145a23a

Please sign in to comment.