mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New config option max_csv_mb limiting size of CSV export - refs #266
This commit is contained in:
parent
619a9ddb33
commit
9d00718250
8 changed files with 89 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from .fixtures import app_client # noqa
|
||||
from .fixtures import app_client, app_client_csv_max_mb_one # noqa
|
||||
|
||||
EXPECTED_TABLE_CSV = '''id,content
|
||||
1,hello
|
||||
|
|
@ -61,6 +61,18 @@ def test_table_csv_download(app_client):
|
|||
assert expected_disposition == response.headers['Content-Disposition']
|
||||
|
||||
|
||||
def test_max_csv_mb(app_client_csv_max_mb_one):
|
||||
response = app_client_csv_max_mb_one.get(
|
||||
"/fixtures.csv?sql=select+randomblob(10000)+"
|
||||
"from+compound_three_primary_keys&_stream=1&_size=max"
|
||||
)
|
||||
# It's a 200 because we started streaming before we knew the error
|
||||
assert response.status == 200
|
||||
# Last line should be an error message
|
||||
last_line = [line for line in response.body.split(b"\r\n") if line][-1]
|
||||
assert last_line.startswith(b"CSV contains more than")
|
||||
|
||||
|
||||
def test_table_csv_stream(app_client):
|
||||
# Without _stream should return header + 100 rows:
|
||||
response = app_client.get(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue