コード例 #1
0
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'
コード例 #2
0
ファイル: test_dumper.py プロジェクト: zzaiin/Rucio
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')