async def test_array_facet_suggest_not_if_all_empty_arrays(app_client): facet = ArrayFacet( app_client.ds, Request.fake("/"), database="fixtures", sql="select * from facetable where tags = '[]'", table="facetable", ) suggestions = await facet.suggest() assert [] == suggestions
async def test_array_facet_results(app_client): facet = ArrayFacet( app_client.ds, MockRequest("http://localhost/?_facet_array=tags"), database="fixtures", sql="select * from facetable", table="facetable", ) buckets, timed_out = await facet.facet_results() assert [] == timed_out assert { "tags": { "name": "tags", "type": "array", "results": [ { "value": "tag1", "label": "tag1", "count": 2, "toggle_url": "http://localhost/?_facet_array=tags&tags__arraycontains=tag1", "selected": False, }, { "value": "tag2", "label": "tag2", "count": 1, "toggle_url": "http://localhost/?_facet_array=tags&tags__arraycontains=tag2", "selected": False, }, { "value": "tag3", "label": "tag3", "count": 1, "toggle_url": "http://localhost/?_facet_array=tags&tags__arraycontains=tag3", "selected": False, }, ], "hideable": True, "toggle_url": "/", "truncated": False, } } == buckets
async def test_array_facet_suggest(app_client): facet = ArrayFacet( app_client.ds, MockRequest("http://localhost/"), database="fixtures", sql="select * from facetable", table="facetable", ) suggestions = await facet.suggest() assert [{ "name": "tags", "type": "array", "toggle_url": "http://localhost/?_facet_array=tags", }] == suggestions