Skip to content

Commit

Permalink
sepalate the test of extended_download
Browse files Browse the repository at this point in the history
  • Loading branch information
To-Ki-O committed Mar 27, 2023
1 parent 1c6f7b8 commit 9380b43
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ckanext/feedback/tests/controllers/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ def test_extended_download(self, mocker):
resource = factories.Resource()
self.app = Flask(__name__)
download = mocker.patch('ckanext.feedback.controllers.download.download')

with self.app.test_request_context(headers={'Sec-Fetch-Dest': 'image'}):
with self.app.test_request_context(headers={'Sec-Fetch-Dest': 'document'}):
DownloadController.extended_download(
'package_type', resource['package_id'], resource['id'], None
)
assert get_downloads(resource['id']) is None
assert get_downloads(resource['id']) == 1
assert download

with self.app.test_request_context(headers={'Sec-Fetch-Dest': 'document'}):
@patch('ckanext.feedback.controllers.download.download')
def test_extended_download_with_preview(self, mocker):
resource = factories.Resource()
self.app = Flask(__name__)
download = mocker.patch('ckanext.feedback.controllers.download.download')

with self.app.test_request_context(headers={'Sec-Fetch-Dest': 'image'}):
DownloadController.extended_download(
'package_type', resource['package_id'], resource['id'], None
)
assert get_downloads(resource['id']) == 1
assert get_downloads(resource['id']) is None
assert download

0 comments on commit 9380b43

Please sign in to comment.