@@ -311,3 +311,72 @@ def test_create_drawing_body_size_within_limit(client: TestClient, valid_kmz_byt
311311 data = {"sha256" : _sha256 (valid_kmz_bytes )},
312312 )
313313 assert response .status_code == 201
314+
315+
316+ def test_delete_drawing_success (client : TestClient , valid_kmz_bytes : bytes ):
317+ """DELETE an existing drawing with the correct admin_id returns 204 and removes it."""
318+ create_resp = client .post (
319+ "/api/wps/v1/drawings" ,
320+ files = {"file" : ("test.kmz" , valid_kmz_bytes , "application/vnd.google-earth.kmz" )},
321+ data = {"sha256" : _sha256 (valid_kmz_bytes )},
322+ )
323+ assert create_resp .status_code == 201
324+ drawing_id = create_resp .json ()["id" ]
325+ admin_id = create_resp .json ()["admin_id" ]
326+
327+ response = client .request (
328+ "DELETE" ,
329+ f"/api/wps/v1/drawings/{ drawing_id } " ,
330+ data = {"admin_id" : admin_id },
331+ )
332+ assert response .status_code == 204
333+
334+ # The drawing must no longer be retrievable
335+ get_resp = client .get (f"/api/wps/v1/drawings/{ drawing_id } " )
336+ assert get_resp .status_code == 404
337+
338+
339+ def test_delete_drawing_wrong_admin_id (client : TestClient , valid_kmz_bytes : bytes ):
340+ """DELETE with a mismatched admin_id returns 403 Forbidden."""
341+ create_resp = client .post (
342+ "/api/wps/v1/drawings" ,
343+ files = {"file" : ("test.kmz" , valid_kmz_bytes , "application/vnd.google-earth.kmz" )},
344+ data = {"sha256" : _sha256 (valid_kmz_bytes )},
345+ )
346+ assert create_resp .status_code == 201
347+ drawing_id = create_resp .json ()["id" ]
348+
349+ response = client .request (
350+ "DELETE" ,
351+ f"/api/wps/v1/drawings/{ drawing_id } " ,
352+ data = {"admin_id" : str (uuid .uuid4 ())},
353+ )
354+ assert response .status_code == 403
355+ assert "detail" in response .json ()
356+
357+
358+ def test_delete_drawing_not_found (client : TestClient ):
359+ """DELETE a non-existent drawing returns 404 Not Found."""
360+ response = client .request (
361+ "DELETE" ,
362+ "/api/wps/v1/drawings/00000000-0000-0000-0000-000000000000" ,
363+ data = {"admin_id" : str (uuid .uuid4 ())},
364+ )
365+ assert response .status_code == 404
366+ assert "detail" in response .json ()
367+
368+
369+ def test_delete_drawing_missing_admin_id (client : TestClient ):
370+ """DELETE without the admin_id form field returns 422 Unprocessable Entity."""
371+ response = client .request ("DELETE" , "/api/wps/v1/drawings/00000000-0000-0000-0000-000000000000" )
372+ assert response .status_code == 422
373+
374+
375+ def test_delete_drawing_invalid_uuid (client : TestClient ):
376+ """DELETE with a malformed UUID returns 422 Unprocessable Entity."""
377+ response = client .request (
378+ "DELETE" ,
379+ "/api/wps/v1/drawings/not-a-valid-uuid" ,
380+ data = {"admin_id" : str (uuid .uuid4 ())},
381+ )
382+ assert response .status_code == 422
0 commit comments