Compare commits

...

2 commits

Author SHA1 Message Date
Simon Willison
7daecbcd32
Order insensitive querystring comparison 2018-05-12 19:47:03 -03:00
Simon Willison
0454c4458f
Fix tests in Python 3.5
In 3.6 dictionaries are ordered, but not in 3.5
2018-05-12 19:37:09 -03:00

View file

@ -99,8 +99,9 @@ def test_existing_filter_redirects(app_client):
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(
'?name__contains=hello&age__gte=22&age__lt=30&name__contains=world'
assert_querystring_equal(
'name__contains=hello&age__gte=22&age__lt=30&name__contains=world',
response.headers['Location'].split('?')[1],
)
# Setting _filter_column_3 to empty string should remove *_3 entirely
@ -108,8 +109,9 @@ def test_existing_filter_redirects(app_client):
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(
'?name__contains=hello&age__gte=22&name__contains=world'
assert_querystring_equal(
'name__contains=hello&age__gte=22&name__contains=world',
response.headers['Location'].split('?')[1],
)
# ?_filter_op=exact should be removed if unaccompanied by _fiter_column
@ -399,6 +401,10 @@ def test_table_metadata(app_client):
assert_footer_links(soup)
def assert_querystring_equal(expected, actual):
assert sorted(expected.split('&')) == sorted(actual.split('&'))
def assert_footer_links(soup):
footer_links = soup.find('div', {'class': 'ft'}).findAll('a')
assert 3 == len(footer_links)