mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Facet class now entirely configured in constructor
This commit is contained in:
parent
8310ad2336
commit
938e072ece
3 changed files with 74 additions and 45 deletions
|
|
@ -8,13 +8,13 @@ import pytest
|
|||
@pytest.mark.asyncio
|
||||
async def test_column_facet_suggest(app_client):
|
||||
facet = ColumnFacet(
|
||||
app_client.ds, MockRequest("http://localhost/"), "fixtures", "facetable", []
|
||||
)
|
||||
suggestions = await facet.suggest(
|
||||
"select * from facetable",
|
||||
[],
|
||||
await app_client.ds.table_count("fixtures", "facetable"),
|
||||
app_client.ds,
|
||||
MockRequest("http://localhost/"),
|
||||
database="fixtures",
|
||||
sql="select * from facetable",
|
||||
table="facetable",
|
||||
)
|
||||
suggestions = await facet.suggest()
|
||||
assert [
|
||||
{"name": "planet_int", "toggle_url": "http://localhost/?_facet=planet_int"},
|
||||
{"name": "on_earth", "toggle_url": "http://localhost/?_facet=on_earth"},
|
||||
|
|
@ -30,16 +30,12 @@ async def test_column_facet_results(app_client):
|
|||
facet = ColumnFacet(
|
||||
app_client.ds,
|
||||
MockRequest("http://localhost/?_facet=city_id"),
|
||||
"fixtures",
|
||||
"facetable",
|
||||
[{"single": "city_id"}],
|
||||
)
|
||||
buckets, timed_out = await facet.facet_results(
|
||||
"""
|
||||
select * from facetable
|
||||
""",
|
||||
[],
|
||||
database="fixtures",
|
||||
sql="select * from facetable",
|
||||
table="facetable",
|
||||
configs=[{"single": "city_id"}],
|
||||
)
|
||||
buckets, timed_out = await facet.facet_results()
|
||||
assert [] == timed_out
|
||||
assert {
|
||||
"city_id": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue