def test_progress_unknown_total_size(self, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when total download size is not known. """ buffer = StringIO() monkeypatch.setattr("sys.stdout", buffer) monkeypatch.setattr("time.time", lambda: 10.0) DownloadHelper.progress(-1, 1024 * 1024, 0.0) assert buffer.getvalue() == "\r [ <=> ] 1.00M in 00:00:10 "
def test_progress_float(self, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when size parameters are passed as floats. """ buffer = StringIO() monkeypatch.setattr("sys.stdout", buffer) monkeypatch.setattr("time.time", lambda: 10.0) DownloadHelper.progress(100.0, 25.0, 0.0) assert buffer.getvalue() == "\r 25%[=======> ] 25.00 eta 00:00:30 "
def test_progress(self, total, downloaded, output, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when size parameters are passed as integers. """ buf = StringIO() monkeypatch.setattr('sys.stdout', buf) monkeypatch.setattr('time.time', lambda: 10.0) DownloadHelper.progress(total, downloaded, 0.0) assert buf.getvalue() == output
def test_progress_float(self, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when size parameters are passed as floats. """ buffer = StringIO() monkeypatch.setattr('sys.stdout', buffer) monkeypatch.setattr('time.time', lambda: 10.0) DownloadHelper.progress(100.0, 25.0, 0.0) assert buffer.getvalue() == ' 25% (00:00:30 remaining)\r'
def test_progress_unknown_total_size(self, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when total download size is not known. """ buffer = StringIO() monkeypatch.setattr('sys.stdout', buffer) monkeypatch.setattr('time.time', lambda: 10.0) DownloadHelper.progress(-1, 1024 * 1024, 0.0) assert buffer.getvalue( ) == '\r [ <=> ] 1.00M in 00:00:10 '
def test_progress_float(self, monkeypatch): """ Test that progress of a download is shown correctly. Test the case when size parameters are passed as floats. """ buffer = StringIO() monkeypatch.setattr('sys.stdout', buffer) monkeypatch.setattr('time.time', lambda: 10.0) DownloadHelper.progress(100.0, 25.0, 0.0) assert buffer.getvalue( ) == '\r 25%[=======> ] 25.00 eta 00:00:30 '