mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Export option: _shape=array&_nl=on for newline-delimited JSON
This commit is contained in:
parent
909cc8fbdf
commit
b5dd83981a
6 changed files with 58 additions and 11 deletions
|
|
@ -9,6 +9,7 @@ from .fixtures import ( # noqa
|
|||
make_app_client,
|
||||
METADATA,
|
||||
)
|
||||
import json
|
||||
import pytest
|
||||
import urllib
|
||||
|
||||
|
|
@ -547,6 +548,27 @@ def test_table_shape_array(app_client):
|
|||
}] == response.json
|
||||
|
||||
|
||||
def test_table_shape_array_nl(app_client):
|
||||
response = app_client.get(
|
||||
'/fixtures/simple_primary_key.json?_shape=array&_nl=on'
|
||||
)
|
||||
lines = response.text.split("\n")
|
||||
results = [json.loads(line) for line in lines]
|
||||
assert [{
|
||||
'id': '1',
|
||||
'content': 'hello',
|
||||
}, {
|
||||
'id': '2',
|
||||
'content': 'world',
|
||||
}, {
|
||||
'id': '3',
|
||||
'content': '',
|
||||
}, {
|
||||
'id': '4',
|
||||
'content': 'RENDER_CELL_DEMO',
|
||||
}] == results
|
||||
|
||||
|
||||
def test_table_shape_invalid(app_client):
|
||||
response = app_client.get(
|
||||
'/fixtures/simple_primary_key.json?_shape=invalid'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue