Add clear GPS endpoint + frontend button
- DELETE /api/assets/{id}/gps sets lat/lng to NULL
- Detail view shows 'Clear GPS' button when asset has GPS coords
- Confirmation modal before clearing
- Tests: 204 success + 404 not found
This commit is contained in:
@@ -432,6 +432,31 @@ class TestDeleteAsset:
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
class TestClearAssetGps:
|
||||
"""Clear GPS endpoint."""
|
||||
|
||||
def test_clear_gps_returns_204(self, client):
|
||||
"""Clear GPS returns 204 and sets lat/lng to null."""
|
||||
r = client.post("/api/assets", json={
|
||||
"machine_id": "GPS001", "name": "Has GPS",
|
||||
"latitude": 28.5, "longitude": -81.3
|
||||
})
|
||||
asset_id = r.json()["id"]
|
||||
response = client.delete(f"/api/assets/{asset_id}/gps")
|
||||
assert response.status_code == 204
|
||||
|
||||
# Verify lat/lng are cleared
|
||||
r2 = client.get(f"/api/assets/{asset_id}")
|
||||
assert r2.status_code == 200
|
||||
data = r2.json()
|
||||
assert data["latitude"] is None
|
||||
assert data["longitude"] is None
|
||||
|
||||
def test_clear_gps_not_found_returns_404(self, client):
|
||||
response = client.delete("/api/assets/99999/gps")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
# ─── Task 7: GET /api/assets/search?machine_id= ───────────────────────────
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user