/db/table/-/blob/pk/column.blob download URL, refs #1036

This commit is contained in:
Simon Willison 2020-10-24 16:09:18 -07:00 committed by GitHub
commit 5a15197960
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 183 additions and 66 deletions

View file

@ -1244,6 +1244,46 @@ def test_binary_data_display(app_client):
]
def test_blob_download(app_client):
response = app_client.get("/fixtures/binary_data/-/blob/1/data.blob")
assert response.status == 200
assert response.body == b"\x15\x1c\x02\xc7\xad\x05\xfe"
assert response.headers["x-content-type-options"] == "nosniff"
assert (
response.headers["content-disposition"]
== 'attachment; filename="binary_data-1-data.blob"'
)
assert response.headers["content-type"] == "application/binary"
@pytest.mark.parametrize(
"path,expected_message",
[
("/baddb/binary_data/-/blob/1/data.blob", "Database baddb does not exist"),
(
"/fixtures/binary_data_bad/-/blob/1/data.blob",
"Table binary_data_bad does not exist",
),
(
"/fixtures/binary_data/-/blob/1/bad.blob",
"Table binary_data does not have column bad",
),
(
"/fixtures/facetable/-/blob/1/state.blob",
"Table facetable does not have column state of type BLOB",
),
(
"/fixtures/binary_data/-/blob/101/data.blob",
"Record not found: ['101']",
),
],
)
def test_blob_download_not_found_messages(app_client, path, expected_message):
response = app_client.get(path)
assert response.status == 404
assert expected_message in response.text
def test_metadata_json_html(app_client):
response = app_client.get("/-/metadata")
assert response.status == 200