Exemplo n.º 1
0
 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 "
Exemplo n.º 2
0
 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 "
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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'
Exemplo n.º 5
0
 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 '
Exemplo n.º 6
0
 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 '