|
11 | 11 | import pytest
|
12 | 12 | import requests
|
13 | 13 |
|
| 14 | +from openeo_driver.config import get_backend_config |
14 | 15 | from openeo_driver.testing import (
|
15 | 16 | ApiTester,
|
16 | 17 | ApproxGeoJSONByBounds,
|
|
22 | 23 | UrllibMocker,
|
23 | 24 | approxify,
|
24 | 25 | caplog_with_custom_formatter,
|
| 26 | + config_overrides, |
25 | 27 | ephemeral_fileserver,
|
26 | 28 | preprocess_check_and_replace,
|
27 | 29 | )
|
@@ -348,3 +350,52 @@ def test_types(self):
|
348 | 350 | expected = ApproxGeoJSONByBounds(1, 1, 3, 4, types=["MultiPolygon"], abs=0.1)
|
349 | 351 | assert geometry != expected
|
350 | 352 | assert "Wrong type 'Polygon'" in repr(expected)
|
| 353 | + |
| 354 | + |
| 355 | +class TestConfigOverrides: |
| 356 | + def test_baseline(self): |
| 357 | + assert get_backend_config().id == "openeo-python-driver-dummy" |
| 358 | + |
| 359 | + def test_context(self): |
| 360 | + assert get_backend_config().id == "openeo-python-driver-dummy" |
| 361 | + with config_overrides(id="hello-inline-context"): |
| 362 | + assert get_backend_config().id == "hello-inline-context" |
| 363 | + assert get_backend_config().id == "openeo-python-driver-dummy" |
| 364 | + |
| 365 | + def test_context_nesting(self): |
| 366 | + assert get_backend_config().id == "openeo-python-driver-dummy" |
| 367 | + with config_overrides(id="hello-inline-context"): |
| 368 | + assert get_backend_config().id == "hello-inline-context" |
| 369 | + with config_overrides(id="hello-again"): |
| 370 | + assert get_backend_config().id == "hello-again" |
| 371 | + assert get_backend_config().id == "hello-inline-context" |
| 372 | + assert get_backend_config().id == "openeo-python-driver-dummy" |
| 373 | + |
| 374 | + @pytest.fixture |
| 375 | + def special_stuff(self): |
| 376 | + with config_overrides(id="hello-fixture"): |
| 377 | + yield |
| 378 | + |
| 379 | + def test_fixture(self, special_stuff): |
| 380 | + assert get_backend_config().id == "hello-fixture" |
| 381 | + |
| 382 | + def test_fixture_and_context(self, special_stuff): |
| 383 | + assert get_backend_config().id == "hello-fixture" |
| 384 | + with config_overrides(id="hello-inline-context"): |
| 385 | + assert get_backend_config().id == "hello-inline-context" |
| 386 | + assert get_backend_config().id == "hello-fixture" |
| 387 | + |
| 388 | + @config_overrides(id="hello-decorator") |
| 389 | + def test_decorator(self): |
| 390 | + assert get_backend_config().id == "hello-decorator" |
| 391 | + |
| 392 | + @config_overrides(id="hello-decorator") |
| 393 | + def test_decorator_and_context(self): |
| 394 | + assert get_backend_config().id == "hello-decorator" |
| 395 | + with config_overrides(id="hello-inline-context"): |
| 396 | + assert get_backend_config().id == "hello-inline-context" |
| 397 | + assert get_backend_config().id == "hello-decorator" |
| 398 | + |
| 399 | + @config_overrides(id="hello-decorator") |
| 400 | + def test_decorator_vs_fixture(self, special_stuff): |
| 401 | + assert get_backend_config().id == "hello-decorator" |
0 commit comments