Esempio n. 1
0
    def test_progress_http(self):
        progress = ProgressPrinter(stream=sys.stdout)

        request = HTTPRequest('http://example.com')
        response = HTTPResponse(206, 'OK')
        response.fields['Content-Size'] = '1024'
        response.fields['Content-Range'] = 'bytes 10-/2048'

        progress.update_from_begin_request(request)
        progress.update_from_begin_response(response)

        for dummy in range(100):
            progress.update_with_data(b'abc')

        progress.update_from_end_response(response)
Esempio n. 2
0
    def test_progress_ftp(self):
        progress = ProgressPrinter(stream=sys.stdout)

        request = FTPRequest('ftp://example.com/example.txt')
        response = FTPResponse()
        response.reply = FTPReply(226, 'Closing data connection')
        response.file_transfer_size = 2048
        response.restart_value = 10

        progress.update_from_begin_request(request)
        progress.update_from_begin_response(response)

        for dummy in range(100):
            progress.update_with_data(b'abc')

        progress.update_from_end_response(response)