1212from stapi_fastapi .models .opportunity import (
1313 Opportunity ,
1414 OpportunityPropertiesBase ,
15+ OpportunityRequest ,
1516)
1617from stapi_fastapi .models .product import Product , Provider , ProviderRole
1718from stapi_fastapi .routers .root_router import RootRouter
1819
19- from .backend import TestProductBackend , TestRootBackend
20+ from .backends import MockOrderDB , MockProductBackend , MockRootBackend
2021
2122
2223class TestSpotlightProperties (OpportunityPropertiesBase ):
2324 off_nadir : int
2425
2526
27+ @pytest .fixture (scope = "session" )
28+ def base_url () -> Iterator [str ]:
29+ yield "http://stapiserver"
30+
31+
2632@pytest .fixture
27- def mock_product_test_spotlight (mock_provider_test : Provider ) -> Product :
33+ def order_db () -> MockOrderDB :
34+ return MockOrderDB ()
35+
36+
37+ @pytest .fixture
38+ def product_backend (order_db : MockOrderDB ) -> MockProductBackend :
39+ return MockProductBackend (order_db )
40+
41+
42+ @pytest .fixture
43+ def root_backend (order_db ) -> MockRootBackend :
44+ return MockRootBackend (order_db )
45+
46+
47+ @pytest .fixture
48+ def mock_product_test_spotlight (
49+ product_backend : MockProductBackend , mock_provider : Provider
50+ ) -> Product :
2851 """Fixture for a mock Test Spotlight product."""
2952 return Product (
3053 id = "test-spotlight" ,
3154 title = "Test Spotlight Product" ,
3255 description = "Test product for test spotlight" ,
3356 license = "CC-BY-4.0" ,
3457 keywords = ["test" , "satellite" ],
35- providers = [mock_provider_test ],
58+ providers = [mock_provider ],
3659 links = [],
3760 constraints = TestSpotlightProperties ,
38- backend = TestProductBackend () ,
61+ backend = product_backend ,
3962 )
4063
4164
42- @pytest .fixture (scope = "session" )
43- def base_url () -> Iterator [str ]:
44- yield "http://stapiserver"
45-
46-
47- @pytest .fixture
48- def product_backend () -> Iterator [TestProductBackend ]:
49- yield TestProductBackend ()
50-
51-
52- @pytest .fixture
53- def root_backend () -> Iterator [TestRootBackend ]:
54- yield TestRootBackend ()
55-
56-
5765@pytest .fixture
5866def stapi_client (
5967 root_backend , mock_product_test_spotlight , base_url : str
@@ -63,7 +71,8 @@ def stapi_client(
6371 app = FastAPI ()
6472 app .include_router (root_router , prefix = "" )
6573
66- yield TestClient (app , base_url = f"{ base_url } " )
74+ with TestClient (app , base_url = f"{ base_url } " ) as client :
75+ yield client
6776
6877
6978@pytest .fixture (scope = "session" )
@@ -83,8 +92,8 @@ def products(mock_product_test_spotlight) -> list[Product]:
8392
8493
8594@pytest .fixture
86- def opportunities (products : list [Product ]) -> Iterator [ list [Opportunity ] ]:
87- yield [
95+ def opportunities (products : list [Product ]) -> list [Opportunity ]:
96+ return [
8897 Opportunity (
8998 geometry = Point (type = "Point" , coordinates = [13.4 , 52.5 ]),
9099 properties = {
@@ -97,7 +106,7 @@ def opportunities(products: list[Product]) -> Iterator[list[Opportunity]]:
97106
98107
99108@pytest .fixture
100- def mock_provider_test () -> Provider :
109+ def mock_provider () -> Provider :
101110 return Provider (
102111 name = "Test Provider" ,
103112 description = "A provider for Test data" ,
@@ -128,3 +137,16 @@ def mock_test_spotlight_opportunities() -> List[Opportunity]:
128137 ),
129138 ),
130139 ]
140+
141+
142+ @pytest .fixture
143+ def allowed_payloads () -> list [OpportunityRequest ]:
144+ return [
145+ OpportunityRequest (
146+ geometry = Point (
147+ type = "Point" , coordinates = Position2D (longitude = 13.4 , latitude = 52.5 )
148+ ),
149+ datetime = (datetime .now (UTC ), datetime .now (UTC )),
150+ filter = {},
151+ ),
152+ ]
0 commit comments