def test_printProgressBarReporting(self): """ L{StdioClient._printProgressBar} prints a progress description, including percent done, amount transferred, transfer rate, and time remaining, all based the given start time, the given L{FileWrapper}'s progress information and the reactor's current time. """ # Use a short, known console width because this simple test doesn't # need to test the console padding. self.setKnownConsoleSize(10, 34) clock = self.client.reactor = Clock() wrapped = BytesIO(b"x") wrapped.name = b"sample" wrapper = cftp.FileWrapper(wrapped) wrapper.size = 1024 * 10 startTime = clock.seconds() clock.advance(2.0) wrapper.total += 4096 self.client._printProgressBar(wrapper, startTime) if _PY3: result = b"\rb'sample' 40% 4.0kB 2.0kBps 00:03 " else: result = "\rsample 40% 4.0kB 2.0kBps 00:03 " self.assertEqual(self.client.transport.value(), result)
def test_printProgressBarEmptyFile(self): """ Print the progress for empty files. """ self.setKnownConsoleSize(10, 34) wrapped = BytesIO() wrapped.name = b'empty-file' wrapper = cftp.FileWrapper(wrapped) self.client._printProgressBar(wrapper, 0) result = b"\rb'empty-file'100% 0.0B 0.0Bps 00:00 " self.assertEqual(result, self.client.transport.value())
def test_printProgressBarEmptyFile(self): """ Print the progress for empty files. """ self.setKnownConsoleSize(10, 34) wrapped = StringIO() wrapped.name = 'empty-file' wrapper = cftp.FileWrapper(wrapped) self.client._printProgressBar(wrapper, 0) self.assertEqual( '\rempty-file100% 0.0B 0.0Bps 00:00 ', self.client.transport.value(), )
def test_reportNoProgress(self): """ L{StdioClient._printProgressBar} prints a progress description that indicates 0 bytes transferred if no bytes have been transferred and no time has passed. """ self.setKnownConsoleSize(10, 34) clock = self.client.reactor = Clock() wrapped = StringIO("x") wrapped.name = "sample" wrapper = cftp.FileWrapper(wrapped) startTime = clock.seconds() self.client._printProgressBar(wrapper, startTime) self.assertEqual(self.client.transport.value(), "\rsample 0% 0.0B 0.0Bps 00:00 ")