Skip to content

Commit

Permalink
Add filename check to download tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
talavis committed Aug 26, 2019
1 parent ac8e1d8 commit ea3bb87
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/modules/browser/tests/test_browser_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ def test_download():
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}'.format(BASE_URL, dataset, data_type, data_item))
assert len(response.text.split('\n')) == 180 # header + 178 + \n
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}/filter/all~false'.format(BASE_URL, dataset, data_type, data_item))
import logging
logging.error(response.text.split('\n'))
assert len(response.text.split('\n')) == 8
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}/filter/all~true'.format(BASE_URL, dataset, data_type, data_item))
assert len(response.text.split('\n')) == 180
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}/filter/mislof~true'.format(BASE_URL, dataset, data_type, data_item))
assert len(response.text.split('\n')) == 2
filename = f'{dataset}_{data_type}_{data_item}.csv'
assert response.headers['content-disposition'] == f'attachment; filename={filename}'

data_type = 'region'
data_item = '22-29450622-29465622'
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}/filter/mislof~false'.format(BASE_URL, dataset, data_type, data_item))
assert len(response.text.split('\n')) == 3
response = requests.get('{}/api/dataset/{}/browser/download/{}/{}/filter/lof~false'.format(BASE_URL, dataset, data_type, data_item))
assert len(response.text.split('\n')) == 3
filename = f'{dataset}_{data_type}_{data_item}.csv'
assert response.headers['content-disposition'] == f'attachment; filename={filename}'


def test_get_coverage():
Expand Down

0 comments on commit ea3bb87

Please sign in to comment.