Just need to fix CSV tests now

pull/1999/head
Simon Willison 2023-03-22 14:58:51 -07:00
rodzic 9b60357f1f
commit e772eb6429
2 zmienionych plików z 19 dodań i 17 usunięć

Wyświetl plik

@ -1564,20 +1564,20 @@ async def table_view_traced(datasette, request):
)
if isinstance(view_data, Response):
return view_data
data, next_url = view_data
data, rows, columns, sql, next_url = view_data
# Handle formats from plugins
if format_ == "csv":
pass
assert False, "CSV not implemented yet"
elif format_ in datasette.renderers.keys():
# Dispatch request to the correct output format renderer
# (CSV is not handled here due to streaming)
result = call_with_supported_arguments(
datasette.renderers[format_][0],
datasette=datasette,
columns=data.get("columns") or [],
rows=data.get("rows") or [],
sql=data.get("query", {}).get("sql", None),
columns=columns,
rows=rows,
sql=sql,
query_name=None,
database=resolved.db.name,
table=resolved.table,
@ -2173,6 +2173,7 @@ async def table_view_data(
link_column=not is_view,
truncate_cells=datasette.setting("truncate_cells_html"),
sortable_columns=sortable_columns,
request=request,
)
return {
"columns": display_columns,
@ -2386,7 +2387,8 @@ async def table_view_data(
if key.startswith("extra_") and key.replace("extra_", "") in extras
}
)
data["rows"] = [dict(r) for r in rows[:page_size]]
raw_sqlite_rows = rows[:page_size]
data["rows"] = [dict(r) for r in raw_sqlite_rows]
if context_for_html_hack:
data.update(extra_context_from_filters)
@ -2428,7 +2430,7 @@ async def table_view_data(
data["sort"] = sort
data["sort_desc"] = sort_desc
return data, next_url
return data, rows[:page_size], columns, sql, next_url
async def _next_value_and_url(

Wyświetl plik

@ -595,42 +595,42 @@ def test_hook_publish_subcommand():
@pytest.mark.asyncio
async def test_hook_register_facet_classes(ds_client):
response = await ds_client.get(
"/fixtures/compound_three_primary_keys.json?_dummy_facet=1"
"/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets"
)
assert [
assert response.json()["suggested_facets"] == [
{
"name": "pk1",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet_dummy=pk1",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet_dummy=pk1",
"type": "dummy",
},
{
"name": "pk2",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet_dummy=pk2",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet_dummy=pk2",
"type": "dummy",
},
{
"name": "pk3",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet_dummy=pk3",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet_dummy=pk3",
"type": "dummy",
},
{
"name": "content",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet_dummy=content",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet_dummy=content",
"type": "dummy",
},
{
"name": "pk1",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet=pk1",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet=pk1",
},
{
"name": "pk2",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet=pk2",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet=pk2",
},
{
"name": "pk3",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet=pk3",
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_extra=suggested_facets&_facet=pk3",
},
] == response.json()["suggested_facets"]
]
@pytest.mark.asyncio