def test_gfal_download_creates_file_with_content(): gfal_file = StringIO() local_file = StringIO() gfal_file.write('content') gfal_file.seek(0) with gfal2.mocked_gfal2(dumper, files={'srm://example.com/file': gfal_file}): with mock_open(dumper, local_file): dumper.gfal_download('srm://example.com/file', 'filename') local_file.seek(0) assert local_file.read() == 'content'
def test_srm_download_creates_file_with_content(): srm_file = StringIO() local_file = StringIO() srm_file.write('content') srm_file.seek(0) with gfal2.mocked_gfal2(dumper, files={'srm://example.com/file': srm_file}): with mock_open(dumper, local_file): dumper.srm_download('srm://example.com/file', 'filename') local_file.seek(0) eq_(local_file.read(), 'content')
def test_http_download_creates_file_with_content(mock_get): response = requests.Response() response.status_code = 200 response.iter_content = lambda _: ['abc'] stringio = StringIO() mock_get.return_value = response with mock_open(dumper, stringio): dumper.http_download('http://example.com', 'filename') stringio.seek(0) assert stringio.read() == 'abc'
def test_http_download_creates_file_with_content(): response = requests.Response() response.status_code = 200 response.iter_content = lambda _: ['abc'] stringio = StringIO() with stubbed(requests.get, lambda _, **kw: response): with mock_open(dumper, stringio): dumper.http_download('http://example.com', 'filename') stringio.seek(0) eq_(stringio.read(), 'abc')