feat: add dex_report_date to AssetCreate model + test for no_dex_days filter
- Add dex_report_date field to AssetCreate Pydantic model - Include dex_report_date in _build_asset_insert columns/values - Add test_list_assets_filter_no_dex_days test (11/11 pass)
This commit is contained in:
@@ -651,6 +651,7 @@ class AssetCreate(BaseModel):
|
||||
is_disney: Optional[bool] = None
|
||||
keys: Optional[List[AssetKey]] = []
|
||||
badges: Optional[List[str]] = []
|
||||
dex_report_date: Optional[str] = None
|
||||
|
||||
|
||||
class AssetUpdate(BaseModel):
|
||||
@@ -889,6 +890,7 @@ def _build_asset_insert(body: AssetCreate, machine_id: str, name: str):
|
||||
"room", "trailer_number", "walking_directions", "map_link",
|
||||
"parking_location", "photo_path", "customer_id", "location_id",
|
||||
"assigned_to", "latitude", "longitude", "geofence_radius_meters", "is_disney",
|
||||
"dex_report_date",
|
||||
]
|
||||
values = (
|
||||
machine_id, body.serial_number or "", name, body.description or "",
|
||||
@@ -902,6 +904,7 @@ def _build_asset_insert(body: AssetCreate, machine_id: str, name: str):
|
||||
body.latitude, body.longitude,
|
||||
body.geofence_radius_meters if body.geofence_radius_meters is not None else 50,
|
||||
body.is_disney if body.is_disney is not None else None,
|
||||
body.dex_report_date,
|
||||
)
|
||||
return columns, values
|
||||
|
||||
|
||||
@@ -1777,6 +1777,15 @@ class TestListAssetsExtendedFilters:
|
||||
assert len(data) == 1
|
||||
assert data[0]["name"] == "Match"
|
||||
|
||||
def test_list_assets_filter_no_dex_days(self, client):
|
||||
"""no_dex_days=N returns assets with no dex report or older than N days."""
|
||||
client.post("/api/assets", json={"machine_id": "DEX1", "name": "HasDex", "dex_report_date": "2026-05-23"})
|
||||
client.post("/api/assets", json={"machine_id": "DEX2", "name": "NoDex"})
|
||||
r = client.get("/api/assets?no_dex_days=5")
|
||||
data = r.json()
|
||||
assert len(data) == 1
|
||||
assert data[0]["name"] == "NoDex"
|
||||
|
||||
|
||||
# ─── Phase C: Users API ──────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user