-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
import responses | ||
|
||
from datapi import Collection | ||
|
||
COLLECTION_URL = ( | ||
"http://localhost:8080/api/catalogue/v1/collections/reanalysis-era5-pressure-levels" | ||
) | ||
COLLECTION_JSON = { | ||
"id": "reanalysis-era5-pressure-levels", | ||
"extent": { | ||
"spatial": {"bbox": [[0.0, -89.0, 360.0, 89.0]]}, | ||
"temporal": {"interval": [["1959-01-01T00:00:00Z", "2025-01-10T00:00:00Z"]]}, | ||
}, | ||
} | ||
|
||
|
||
@pytest.fixture | ||
@responses.activate | ||
def collection() -> Collection: | ||
responses.add( | ||
responses.GET, | ||
COLLECTION_URL, | ||
json=COLLECTION_JSON, | ||
status=200, | ||
content_type="application/json", | ||
) | ||
return Collection.from_request( | ||
"get", | ||
COLLECTION_URL, | ||
headers={}, | ||
session=None, | ||
retry_options={"maximum_tries": 1}, | ||
request_options={}, | ||
download_options={}, | ||
sleep_max=120, | ||
cleanup=False, | ||
log_callback=None, | ||
) | ||
|
||
|
||
def test_catalogue_collection_begin_datetime(collection: Collection) -> None: | ||
assert collection.begin_datetime is not None | ||
assert collection.begin_datetime.isoformat() == "1959-01-01T00:00:00+00:00" | ||
|
||
|
||
def test_catalogue_collection_end_datetime(collection: Collection) -> None: | ||
assert collection.end_datetime is not None | ||
assert collection.end_datetime.isoformat() == "2025-01-10T00:00:00+00:00" | ||
|
||
|
||
def test_catalogue_collection_bbox(collection: Collection) -> None: | ||
assert collection.bbox == (0, -89, 360, 89) | ||
|
||
|
||
def test_catalogue_collection_id(collection: Collection) -> None: | ||
assert collection.id == "reanalysis-era5-pressure-levels" | ||
|
||
|
||
def test_catalogue_collection_json(collection: Collection) -> None: | ||
assert collection.json == COLLECTION_JSON | ||
|
||
|
||
def test_catalogue_collection_url(collection: Collection) -> None: | ||
assert collection.url == COLLECTION_URL |