MCPcopy
hub / github.com/streamlit/streamlit / test_upload_delete_endpoint

Function test_upload_delete_endpoint

e2e_playwright/web_server_test.py:473–488  ·  view source on GitHub ↗

Test that upload DELETE endpoint responds correctly. When XSRF protection is enabled (default), the server will return 403 Forbidden for requests without a valid XSRF token. When XSRF is disabled, it returns 204 No Content for DELETE operations.

(app: Page, app_base_url: str)

Source from the content-addressed store, hash-verified

471
472
473def test_upload_delete_endpoint(app: Page, app_base_url: str):
474 """Test that upload DELETE endpoint responds correctly.
475
476 When XSRF protection is enabled (default), the server will return 403 Forbidden
477 for requests without a valid XSRF token.
478 When XSRF is disabled, it returns 204 No Content for DELETE operations.
479 """
480 wait_for_app_loaded(app)
481
482 # DELETE on a non-existent file
483 response = app.request.delete(
484 build_app_url(app_base_url, path="/_stcore/upload_file/any-session/any-file")
485 )
486
487 # Should return 204 (success) or 403 (XSRF protection)
488 assert response.status in {204, 403}, f"Expected 204 or 403, got {response.status}"
489
490
491# =============================================================================

Callers

nothing calls this directly

Calls 3

wait_for_app_loadedFunction · 0.90
build_app_urlFunction · 0.90
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…