def test_download_status(monkeypatch, tmpdir): resp = FakeResponse() resp.status_code = 418 monkeypatch.setattr('requests.get', resp) with pytest.raises(IOError): walls.download('file.txt', str(tmpdir))
def test_download_real_status(monkeypatch, tmpdir): with pytest.raises(IOError): walls.download('http://0.0.0.0:1234', str(tmpdir))
def test_download(monkeypatch, tmpdir): resp = FakeResponse() resp.status_code = 200 monkeypatch.setattr('requests.get', resp) walls.download('file.txt', str(tmpdir)) assert tmpdir.join('file.txt').read() == 'this is the data'