mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Facet "selected" key and toggle_url now toggles, refs #255
This commit is contained in:
parent
2b79f2bdeb
commit
cf6e7840ae
5 changed files with 54 additions and 8 deletions
|
|
@ -897,11 +897,13 @@ def test_page_size_matching_max_returned_rows(app_client_returend_rows_matches_p
|
|||
{
|
||||
"value": "CA",
|
||||
"count": 10,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&state=CA",
|
||||
},
|
||||
{
|
||||
"value": "MI",
|
||||
"count": 4,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&state=MI",
|
||||
},
|
||||
],
|
||||
|
|
@ -909,16 +911,19 @@ def test_page_size_matching_max_returned_rows(app_client_returend_rows_matches_p
|
|||
{
|
||||
"value": "San Francisco",
|
||||
"count": 6,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&city=San+Francisco",
|
||||
},
|
||||
{
|
||||
"value": "Detroit",
|
||||
"count": 4,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&city=Detroit",
|
||||
},
|
||||
{
|
||||
"value": "Los Angeles",
|
||||
"count": 4,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&city=Los+Angeles",
|
||||
},
|
||||
],
|
||||
|
|
@ -930,13 +935,15 @@ def test_page_size_matching_max_returned_rows(app_client_returend_rows_matches_p
|
|||
{
|
||||
"value": "MI",
|
||||
"count": 4,
|
||||
"toggle_url": "_facet=state&_facet=city&state=MI",
|
||||
"selected": True,
|
||||
"toggle_url": "_facet=state&_facet=city",
|
||||
},
|
||||
],
|
||||
"city": [
|
||||
{
|
||||
"value": "Detroit",
|
||||
"count": 4,
|
||||
"selected": False,
|
||||
"toggle_url": "_facet=state&_facet=city&state=MI&city=Detroit",
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -45,6 +45,19 @@ def test_path_with_added_args(path, added_args, expected):
|
|||
assert expected == actual
|
||||
|
||||
|
||||
@pytest.mark.parametrize('path,args,expected', [
|
||||
('/foo?bar=1', {'bar'}, '/foo'),
|
||||
('/foo?bar=1&baz=2', {'bar'}, '/foo?baz=2'),
|
||||
])
|
||||
def test_path_with_removed_args(path, args, expected):
|
||||
request = Request(
|
||||
path.encode('utf8'),
|
||||
{}, '1.1', 'GET', None
|
||||
)
|
||||
actual = utils.path_with_removed_args(request, args)
|
||||
assert expected == actual
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row,pks,expected_path', [
|
||||
({'A': 'foo', 'B': 'bar'}, ['A', 'B'], 'foo,bar'),
|
||||
({'A': 'f,o', 'B': 'bar'}, ['A', 'B'], 'f%2Co,bar'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue