예제 #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')