Skip to content

Commit

Permalink
Sins acknowledged
Browse files Browse the repository at this point in the history
  • Loading branch information
jsignell committed Apr 17, 2024
1 parent 261738c commit 4b1846b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion stat_fastapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
OpportunityCollection,
OpportunitySearch,
)
from stat_fastapi.models.order import Order
from stat_fastapi.models.order import Order
from stat_fastapi.models.product import Product, ProductsCollection
from stat_fastapi.models.root import RootResponse
from stat_fastapi.models.shared import HTTPException as HTTPExceptionModel
Expand Down
7 changes: 5 additions & 2 deletions stat_fastapi/models/opportunity.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
from typing import Any, Literal, Mapping
from typing import Literal

from geojson_pydantic import Feature, FeatureCollection
from geojson_pydantic.geometries import Geometry

from pydantic import BaseModel

from stat_fastapi.models.constraints import Constraints
from stat_fastapi.types.datetime_interval import DatetimeInterval


# Copied and modified from stack_pydantic.item.ItemProperties
class OpportunityProperties(BaseModel):
datetime: DatetimeInterval
product_id: str
constraints: Constraints


class OpportunitySearch(OpportunityProperties):
geometry: Geometry


class Opportunity(Feature[Geometry, OpportunityProperties]):
type: Literal["Feature"] = "Feature"


class OpportunityCollection(FeatureCollection[Opportunity]):
type: Literal["FeatureCollection"] = "FeatureCollection"
5 changes: 1 addition & 4 deletions stat_fastapi_test_backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def product(self, product_id: str, request: Request) -> Product | None:
async def search_opportunities(
self, search: OpportunitySearch, request: Request
) -> list[Opportunity]:
return [
o.model_copy(update=search.model_dump())
for o in self._opportunities
]
return [o.model_copy(update=search.model_dump()) for o in self._opportunities]

async def create_order(self, payload: OpportunitySearch, request: Request) -> Order:
"""
Expand Down
2 changes: 1 addition & 1 deletion stat_fastapi_tle_backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from stat_fastapi.models.opportunity import Opportunity, OpportunitySearch
from stat_fastapi.models.order import Order
from stat_fastapi.models.product import Product, Provider, ProviderRole

from stat_fastapi_tle_backend.models import ValidatedOpportunitySearch
from stat_fastapi_tle_backend.repository import Repository
from stat_fastapi_tle_backend.satellite import EarthObservationSatelliteModel
from stat_fastapi_tle_backend.settings import Settings


class OffNadirRange(BaseModel):
minimum: float = Field(ge=0.0, le=45)
maximum: float = Field(ge=0.0, le=45)
Expand Down
3 changes: 1 addition & 2 deletions tests/order_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ def test_get_order_properties(get_order_response: Response, allowed_payloads):
}

assert (
order["properties"]["datetime"]
== allowed_payloads[0].model_dump()["datetime"]
order["properties"]["datetime"] == allowed_payloads[0].model_dump()["datetime"]
)

0 comments on commit 4b1846b

Please sign in to comment.