Files
Ai/TESTING.md
T
2026-05-10 22:49:07 +03:30

3.2 KiB

Local Test Workflow

This project can be tested in a local virtualenv that mirrors the Python package source used by the Docker images.

1. Create the virtualenv

python3 -m venv .venv-test
source .venv-test/bin/activate

2. Install dependencies with the Docker mirror

Option A: full project install

Use this when your local Python version matches Docker (3.10).

The development Docker image installs packages from https://mirror-pypi.runflare.com/simple.

source .venv-test/bin/activate
pip --isolated install \
  --prefer-binary \
  --index-url https://mirror-pypi.runflare.com/simple \
  --trusted-host mirror-pypi.runflare.com \
  -c constraints.txt \
  -r requirements.txt

Option B: focused openEO test install

I used this path successfully on a host with Python 3.14, where the pinned full requirements are not Docker-compatible because the project pins older numpy for Python 3.10.

source .venv-test/bin/activate
pip --isolated install \
  --prefer-binary \
  --index-url https://mirror-pypi.runflare.com/simple \
  --trusted-host mirror-pypi.runflare.com \
  Django \
  requests \
  PySocks \
  openeo \
  python-dotenv \
  Pillow

If the mirror is temporarily slow in your environment, retry the same command once more before changing indexes.

3. Run the focused openEO test file

Standard Django command

source .venv-test/bin/activate
python manage.py test location_data.test_openeo_service

Minimal runner used on a non-Docker local setup

This avoids loading the whole project URL tree and only boots the apps needed by location_data.test_openeo_service.

source .venv-test/bin/activate
python - <<'PY'
import sys, types
import django
from django.conf import settings
from django.urls import path

url_module = types.ModuleType("local_test_urls")
url_module.urlpatterns = [path("__test__/", lambda request: None)]
sys.modules["local_test_urls"] = url_module

settings.configure(
    SECRET_KEY="test-secret",
    USE_TZ=True,
    DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
    INSTALLED_APPS=[
        "django.contrib.auth",
        "django.contrib.contenttypes",
        "location_data",
    ],
    MIDDLEWARE=[],
    ROOT_URLCONF="local_test_urls",
    DEFAULT_AUTO_FIELD="django.db.models.BigAutoField",
)

django.setup()
from django.test.utils import get_runner

runner = get_runner(settings)()
failures = runner.run_tests(["location_data.test_openeo_service"])
raise SystemExit(bool(failures))
PY

4. Run the broader location-data suite

source .venv-test/bin/activate
python manage.py test location_data

5. Run a syntax-only validation

This is useful when dependencies are still being installed or when you want a very fast sanity check.

python3 -m py_compile \
  location_data/openeo_service.py \
  location_data/tasks.py \
  location_data/test_openeo_service.py \
  config/proxy.py

Notes

  • The openEO request timeout is configured through OPENEO_TIMEOUT_SECONDS.
  • The current default in code and .env.example is 600 seconds.
  • openEO request logging is emitted from location_data.openeo_service, including request payloads, process graphs, downloaded batch result files, and parse failures.