Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit c6ca74b

Browse files
committed
review: more test cleanup
1 parent 734180c commit c6ca74b

File tree

1 file changed

+9
-46
lines changed

1 file changed

+9
-46
lines changed

tests/conftest.py

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,17 @@
1616
)
1717
from stapi_fastapi.models.product import (
1818
Product,
19-
Provider,
20-
ProviderRole,
2119
)
2220
from stapi_fastapi.routers.root_router import RootRouter
2321

2422
from .application import (
2523
InMemoryOrderDB,
2624
MyOpportunityProperties,
27-
MyOrderParameters,
28-
MyProductConstraints,
2925
OffNadirRange,
30-
mock_create_order,
3126
mock_get_order,
3227
mock_get_order_statuses,
3328
mock_get_orders,
34-
mock_search_opportunities,
29+
product,
3530
)
3631
from .shared import find_link
3732

@@ -42,41 +37,23 @@ def base_url() -> Iterator[str]:
4237

4338

4439
@pytest.fixture
45-
def mock_product_test_spotlight(
46-
mock_provider: Provider,
47-
) -> Product:
40+
def mock_product() -> Product:
4841
"""Fixture for a mock Test Spotlight product."""
49-
return Product(
50-
id="test-spotlight",
51-
title="Test Spotlight Product",
52-
description="Test product for test spotlight",
53-
license="CC-BY-4.0",
54-
keywords=["test", "satellite"],
55-
providers=[mock_provider],
56-
links=[],
57-
constraints=MyProductConstraints,
58-
opportunity_properties=MyOpportunityProperties,
59-
order_parameters=MyOrderParameters,
60-
create_order=mock_create_order,
61-
search_opportunities=mock_search_opportunities,
62-
)
42+
return product
6343

6444

6545
@pytest.fixture
6646
def stapi_client(
67-
mock_product_test_spotlight,
47+
mock_product,
6848
base_url: str,
69-
orders_db: InMemoryOrderDB | None = None,
70-
opportunities: list[Opportunity] | None = None,
49+
mock_opportunities: list[Opportunity],
7150
) -> Iterator[TestClient]:
7251
@asynccontextmanager
7352
async def lifespan(app: FastAPI) -> AsyncIterator[dict[str, Any]]:
7453
try:
7554
yield {
76-
"_orders_db": orders_db if orders_db is not None else InMemoryOrderDB(),
77-
"_opportunities": opportunities
78-
if opportunities is not None
79-
else mock_test_spotlight_opportunities(),
55+
"_orders_db": InMemoryOrderDB(),
56+
"_opportunities": mock_opportunities,
8057
}
8158
finally:
8259
pass
@@ -86,7 +63,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[dict[str, Any]]:
8663
get_order=mock_get_order,
8764
get_order_statuses=mock_get_order_statuses,
8865
)
89-
root_router.add_product(mock_product_test_spotlight)
66+
root_router.add_product(mock_product)
9067
app = FastAPI(lifespan=lifespan)
9168
app.include_router(root_router, prefix="")
9269

@@ -123,21 +100,7 @@ def _assert_link(
123100

124101

125102
@pytest.fixture
126-
def products(mock_product_test_spotlight: Product) -> list[Product]:
127-
return [mock_product_test_spotlight]
128-
129-
130-
@pytest.fixture
131-
def mock_provider() -> Provider:
132-
return Provider(
133-
name="Test Provider",
134-
description="A provider for Test data",
135-
roles=[ProviderRole.producer], # Example role
136-
url="https://test-provider.example.com", # Must be a valid URL
137-
)
138-
139-
140-
def mock_test_spotlight_opportunities() -> list[Opportunity]:
103+
def mock_opportunities() -> list[Opportunity]:
141104
"""Fixture to create mock data for Opportunities for `test-spotlight-1`."""
142105
now = datetime.now(timezone.utc) # Use timezone-aware datetime
143106
start = now

0 commit comments

Comments
 (0)