Skip to content

Commit

Permalink
Mocking download
Browse files Browse the repository at this point in the history
  • Loading branch information
Raahul Singh committed Feb 27, 2020
1 parent b68100e commit 1930c29
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sunpy/net/jsoc/tests/test_jsoc.py
Expand Up @@ -7,6 +7,7 @@
import astropy.units as u
import pytest
from parfive import Results
from unittest import mock

from sunpy.net.jsoc import JSOCClient, JSOCResponse
import sunpy.net.attrs as a
Expand Down Expand Up @@ -326,7 +327,17 @@ def test_max_parallel_connections():
responses = client.search(
a.Time('2014/1/1T1:00:36', '2014/1/1T01:01:38'),
a.jsoc.Series('hmi.M_45s'), a.jsoc.Notify('jsoc@cadair.com'))

path = tempfile.mkdtemp()

with pytest.warns(SunpyUserWarning):
client.fetch(responses, path=path, max_conn=5, max_splits=5)
with mock.patch(
"parfive.Downloader.download",
new_callable=mock.MagicMock
) as download:

download.side_effect = ["Mocked Downloader"]

with pytest.warns(SunpyUserWarning):
client.fetch(responses, path=path, max_conn=5, max_splits=5)

assert download.called

0 comments on commit 1930c29

Please sign in to comment.