table facet_size in metadata, refs #1804

This commit is contained in:
Simon Willison 2022-09-06 08:59:19 -07:00
commit 8430c3bc7d
2 changed files with 28 additions and 3 deletions

View file

@ -581,6 +581,23 @@ async def test_facet_size():
)
data5 = response5.json()
assert len(data5["facet_results"]["city"]["results"]) == 20
# Now try messing with facet_size in the table metadata
ds._metadata_local = {
"databases": {
"test_facet_size": {"tables": {"neighbourhoods": {"facet_size": 6}}}
}
}
response6 = await ds.client.get("/test_facet_size/neighbourhoods.json?_facet=city")
data6 = response6.json()
assert len(data6["facet_results"]["city"]["results"]) == 6
# Setting it to max bumps it up to 50 again
ds._metadata_local["databases"]["test_facet_size"]["tables"]["neighbourhoods"][
"facet_size"
] = "max"
data7 = (
await ds.client.get("/test_facet_size/neighbourhoods.json?_facet=city")
).json()
assert len(data7["facet_results"]["city"]["results"]) == 20
def test_other_types_of_facet_in_metadata():