From 850bae196d97dc616f712e0304a6f9e5d68b4083 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Tue, 3 Dec 2024 23:41:11 +0100 Subject: [PATCH] fixup! fixup! fixup! Issue #332 introduce support for job listing pagination --- openeo_driver/dummy/dummy_backend.py | 61 ++++++++++++++++------------ tests/test_views.py | 43 ++++++++++++++------ 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/openeo_driver/dummy/dummy_backend.py b/openeo_driver/dummy/dummy_backend.py index 2ab0edf0..f54741b1 100644 --- a/openeo_driver/dummy/dummy_backend.py +++ b/openeo_driver/dummy/dummy_backend.py @@ -1,41 +1,47 @@ +import importlib.metadata import json import numbers +import unittest.mock from datetime import datetime from functools import lru_cache from pathlib import Path -from typing import List, Dict, Union, Tuple, Optional, Iterable, Any, Sequence -import unittest.mock +from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union from unittest.mock import Mock -import importlib.metadata import flask import numpy -import xarray -from shapely.geometry import Polygon, MultiPolygon -from shapely.geometry.base import BaseGeometry, BaseMultipartGeometry -from shapely.geometry.collection import GeometryCollection +import openeo.udf import werkzeug.datastructures - +import xarray from openeo.api.logs import normalize_log_level from openeo.internal.process_graph_visitor import ProcessGraphVisitor -from openeo.metadata import CollectionMetadata, Band, SpatialDimension, TemporalDimension, BandDimension -import openeo.udf +from openeo.metadata import ( + Band, + BandDimension, + CollectionMetadata, + SpatialDimension, + TemporalDimension, +) from openeo.util import rfc3339 -from openeo_driver.ProcessGraphDeserializer import ConcreteProcessing +from shapely.geometry import MultiPolygon, Polygon +from shapely.geometry.base import BaseGeometry, BaseMultipartGeometry +from shapely.geometry.collection import GeometryCollection + +import openeo_driver.util.changelog from openeo_driver.backend import ( - SecondaryServices, - OpenEoBackendImplementation, - CollectionCatalog, - ServiceMetadata, - BatchJobs, BatchJobMetadata, + BatchJobResultMetadata, + BatchJobs, + CollectionCatalog, + JobListing, + LoadParameters, OidcProvider, + OpenEoBackendImplementation, + Processing, + SecondaryServices, + ServiceMetadata, UserDefinedProcesses, UserDefinedProcessMetadata, - LoadParameters, - Processing, - BatchJobResultMetadata, - JobListing, ) from openeo_driver.config import OpenEoBackendConfig from openeo_driver.constants import STAC_EXTENSION @@ -44,18 +50,21 @@ from openeo_driver.delayed_vector import DelayedVector from openeo_driver.dry_run import SourceConstraint from openeo_driver.errors import ( - JobNotFoundException, + FeatureUnsupportedException, JobNotFinishedException, - ProcessGraphNotFoundException, + JobNotFoundException, PermissionsInsufficientException, - FeatureUnsupportedException, + ProcessGraphNotFoundException, ) from openeo_driver.jobregistry import JOB_STATUS -from openeo_driver.save_result import AggregatePolygonResult, AggregatePolygonSpatialResult +from openeo_driver.ProcessGraphDeserializer import ConcreteProcessing +from openeo_driver.save_result import ( + AggregatePolygonResult, + AggregatePolygonSpatialResult, +) from openeo_driver.users import User -import openeo_driver.util.changelog from openeo_driver.util.http import UrlSafeStructCodec -from openeo_driver.utils import EvalEnv, generate_unique_id, WhiteListEvalEnv +from openeo_driver.utils import EvalEnv, WhiteListEvalEnv, generate_unique_id DEFAULT_DATETIME = datetime(2020, 4, 23, 16, 20, 27) diff --git a/tests/test_views.py b/tests/test_views.py index c136b8ca..c9cd0ffa 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,4 +1,3 @@ -import dirty_equals import json import logging import re @@ -10,43 +9,61 @@ from unittest import mock import boto3 +import dirty_equals import flask +import geopandas as gpd +import moto import pystac.validation.stac_validator import pytest import re_assert import werkzeug.exceptions -import moto -import geopandas as gpd - from openeo.capabilities import ComparableVersion -from openeo_driver.ProcessGraphDeserializer import custom_process_from_process_graph + from openeo_driver.backend import ( BatchJobMetadata, - UserDefinedProcessMetadata, + BatchJobResultMetadata, BatchJobs, OpenEoBackendImplementation, Processing, + UserDefinedProcessMetadata, not_implemented, - BatchJobResultMetadata, ) from openeo_driver.config import OpenEoBackendConfig from openeo_driver.datacube import DriverVectorCube from openeo_driver.dummy import dummy_backend, dummy_config from openeo_driver.dummy.dummy_backend import DummyBackendImplementation from openeo_driver.errors import OpenEOApiException +from openeo_driver.ProcessGraphDeserializer import custom_process_from_process_graph from openeo_driver.save_result import VectorCubeResult -from openeo_driver.testing import ApiTester, TEST_USER, ApiResponse, TEST_USER_AUTH_HEADER, \ - generate_unique_test_process_id, build_basic_http_auth_header, ListSubSet, DictSubSet, RegexMatcher +from openeo_driver.testing import ( + TEST_USER, + TEST_USER_AUTH_HEADER, + ApiResponse, + ApiTester, + DictSubSet, + ListSubSet, + RegexMatcher, + build_basic_http_auth_header, + generate_unique_test_process_id, +) from openeo_driver.urlsigning import UrlSigner from openeo_driver.users import User -from openeo_driver.users.auth import HttpAuthHandler, AccessTokenException +from openeo_driver.users.auth import AccessTokenException, HttpAuthHandler from openeo_driver.users.oidc import OidcProvider -from openeo_driver.util.logging import LOGGING_CONTEXT_FLASK, FlaskRequestCorrelationIdLogging -from openeo_driver.views import EndpointRegistry, _normalize_collection_metadata, build_app, STREAM_CHUNK_SIZE_DEFAULT +from openeo_driver.util.logging import ( + LOGGING_CONTEXT_FLASK, + FlaskRequestCorrelationIdLogging, +) +from openeo_driver.views import ( + STREAM_CHUNK_SIZE_DEFAULT, + EndpointRegistry, + _normalize_collection_metadata, + build_app, +) + from .conftest import TEST_APP_CONFIG, enhanced_logging from .data import TEST_DATA_ROOT, get_path - EXPECTED_PROCESSING_EXPRESSION = {"expression": {"process_graph": {"foo": {"process_id": "foo", "arguments": {}}}}, "format": "openeo"}