mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Select option for removing filters
This commit is contained in:
parent
22b91dd95b
commit
ef3eacf622
4 changed files with 44 additions and 21 deletions
|
|
@ -303,7 +303,7 @@ def test_add_filter_redirects(app_client):
|
|||
|
||||
|
||||
def test_existing_filter_redirects(app_client):
|
||||
filter_args = urllib.parse.urlencode({
|
||||
filter_args = {
|
||||
'_filter_column_1': 'name',
|
||||
'_filter_op_1': 'contains',
|
||||
'_filter_value_1': 'hello',
|
||||
|
|
@ -316,17 +316,31 @@ def test_existing_filter_redirects(app_client):
|
|||
'_filter_column_4': 'name',
|
||||
'_filter_op_4': 'contains',
|
||||
'_filter_value_4': 'world',
|
||||
})
|
||||
}
|
||||
path_base = app_client.get(
|
||||
'/test_tables/simple_primary_key', allow_redirects=False, gather_request=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + filter_args
|
||||
path = path_base + '?' + urllib.parse.urlencode(filter_args)
|
||||
response = app_client.get(path, allow_redirects=False, gather_request=False)
|
||||
assert response.status == 302
|
||||
assert response.headers['Location'].endswith(
|
||||
'?age__gte=22&age__lt=30&name__contains=hello&name__contains=world'
|
||||
)
|
||||
|
||||
# Setting _filter_column_3 to empty string should remove *_3 entirely
|
||||
filter_args['_filter_column_3'] = ''
|
||||
path = path_base + '?' + urllib.parse.urlencode(filter_args)
|
||||
response = app_client.get(path, allow_redirects=False, gather_request=False)
|
||||
assert response.status == 302
|
||||
assert response.headers['Location'].endswith(
|
||||
'?age__gte=22&name__contains=hello&name__contains=world'
|
||||
)
|
||||
|
||||
# ?_filter_op=exact should be removed if unaccompanied by _fiter_column
|
||||
response = app_client.get(path_base + '?_filter_op=exact', allow_redirects=False, gather_request=False)
|
||||
assert response.status == 302
|
||||
assert '?' not in response.headers['Location']
|
||||
|
||||
|
||||
TABLES = '''
|
||||
CREATE TABLE simple_primary_key (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue