Add clear asset GPS endpoint + UI

- DELETE /api/assets/{id}/gps: clears lat/lng to NULL
- GET /api/assets/{id}: asset lookup by ID
- GET /api/assets/search?machine_id=: asset lookup by machine ID
- Export & Admin page: Clear Asset GPS card with lookup + confirmation
- Tests: 204 success + 404 not found
This commit is contained in:
Leo
2026-05-22 23:36:40 -04:00
parent ae20c0507f
commit 9794d8076c
3 changed files with 137 additions and 0 deletions
+29
View File
@@ -288,3 +288,32 @@ class TestSettings:
cid = _assert_created(client.post("/api/settings/categories", json={"name": name}), "category")
resp = client.delete(f"/api/settings/categories/{cid}")
assert resp.status_code == 204
# ─── Asset GPS ──────────────────────────────────────────────────────────────
class TestClearAssetGps:
def test_clear_gps_returns_204(self, client):
"""Clear GPS returns 204 and sets lat/lng to null."""
# Create an asset with GPS coords via direct DB insert
import sqlite3
conn = sqlite3.connect(DB_PATH)
conn.execute(
"INSERT INTO assets (machine_id, name, latitude, longitude) VALUES (?, ?, ?, ?)",
("GPS-ADMIN-TEST", "Test GPS Asset", 28.5, -81.3),
)
asset_id = conn.execute("SELECT last_insert_rowid()").fetchone()[0]
conn.commit()
conn.close()
resp = client.delete(f"/api/assets/{asset_id}/gps")
assert resp.status_code == 204
# Verify
data = _assert_ok(client.get(f"/api/assets/{asset_id}"), "asset")
assert data["latitude"] is None
assert data["longitude"] is None
def test_clear_gps_not_found_returns_404(self, client):
resp = client.delete("/api/assets/99999/gps")
assert resp.status_code == 404