-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #668 some final tweaks and tests
- Loading branch information
Showing
4 changed files
with
190 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import pytest | ||
|
||
from openeo.rest.models.federation_extension import ( | ||
get_backend_details, | ||
get_federation_missing, | ||
) | ||
|
||
|
||
def test_get_backend_details(): | ||
assert get_backend_details({}) is None | ||
assert get_backend_details( | ||
{ | ||
"api_version": "1.2.0", | ||
"backend_version": "1.1.2", | ||
"stac_version": "1.0.0", | ||
"type": "Catalog", | ||
"id": "cool-eo-cloud", | ||
"endpoints": [ | ||
{"path": "/collections", "methods": ["GET"]}, | ||
], | ||
"federation": { | ||
"eoa": {"title": "EO Answers", "url": "https://eoe.test/go"}, | ||
"eob": {"title": "Beyond EO", "url": "https://eoeb.example.com"}, | ||
}, | ||
} | ||
) == { | ||
"eoa": {"title": "EO Answers", "url": "https://eoe.test/go"}, | ||
"eob": {"title": "Beyond EO", "url": "https://eoeb.example.com"}, | ||
} | ||
|
||
|
||
def test_get_federation_missing(): | ||
assert get_federation_missing({}, resource_name="things") is None | ||
assert get_federation_missing( | ||
{ | ||
"things": ["apple", "banana"], | ||
"federation:missing": ["veggies"], | ||
}, | ||
resource_name="things", | ||
) == ["veggies"] | ||
|
||
|
||
@pytest.mark.parametrize(["auto_warn"], [[True], [False]]) | ||
def test_get_federation_missing_auto_warn(auto_warn, caplog): | ||
assert get_federation_missing( | ||
{ | ||
"things": ["apple", "banana"], | ||
"federation:missing": ["veggies"], | ||
}, | ||
resource_name="things", | ||
auto_warn=auto_warn, | ||
) == ["veggies"] | ||
|
||
if auto_warn: | ||
assert "Partial things: missing federation components: ['veggies']." in caplog.text | ||
else: | ||
assert caplog.text == "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters