init
This commit is contained in:
30 files changed
+1757
No files matched your search
@@ -0,0 +1,63 @@
|
||||
from collections.abc import AsyncIterator
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from warehouse_allocation.api import create_app
|
||||
from warehouse_allocation.config import Settings
|
||||
from warehouse_allocation.infrastructure.inventory import InMemoryInventoryRepository
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inventory() -> InMemoryInventoryRepository:
|
||||
return InMemoryInventoryRepository()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def client(
|
||||
inventory: InMemoryInventoryRepository,
|
||||
) -> AsyncIterator[httpx.AsyncClient]:
|
||||
app = create_app(Settings(inventory_backend="memory"), inventory)
|
||||
async with app.router.lifespan_context(app):
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def allocation_payload() -> dict[str, object]:
|
||||
return {
|
||||
"requestId": "order-1001",
|
||||
"customerLocation": {"latitude": 35.7219, "longitude": 51.3347},
|
||||
"items": [{"sku": "SKU-RED-42", "quantity": 2}],
|
||||
"transportationCosts": [
|
||||
{
|
||||
"warehouseId": "tehran-west",
|
||||
"fixedCost": 100,
|
||||
"distanceKm": 12,
|
||||
"costPerKm": 2,
|
||||
"baseDeliveryMinutes": 60,
|
||||
},
|
||||
{
|
||||
"warehouseId": "karaj",
|
||||
"fixedCost": 90,
|
||||
"distanceKm": 50,
|
||||
"costPerKm": 2,
|
||||
"baseDeliveryMinutes": 100,
|
||||
},
|
||||
],
|
||||
"logisticsConstraints": [
|
||||
{
|
||||
"warehouseId": "tehran-west",
|
||||
"trafficMultiplier": 1.2,
|
||||
"fleetPriority": 1.1,
|
||||
"handlingMinutes": 10,
|
||||
},
|
||||
{
|
||||
"warehouseId": "karaj",
|
||||
"trafficMultiplier": 1,
|
||||
"fleetPriority": 1,
|
||||
"handlingMinutes": 10,
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in new issue
Block a user