# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()
# 
# Path: rebasehelper/helpers/download_helper.py
# class DownloadHelper:
#         class FTPAdapter(requests.adapters.BaseAdapter):
#     def progress(download_total, downloaded, start_time, show_size=True):
#         def format_time(t):
#         def format_size(s):
#     def request(url, **kwargs):
#             def send(self, request, stream=False, timeout=None, verify=True,  # pylint: disable=unused-argument
#                      cert=None, proxies=None):  # pylint: disable=unused-argument
#             def close(self):
#     def download_file(url, destination_path, blocksize=8192):


import io
import os
import pytest  # type: ignore
from rebasehelper.constants import ENCODING
from rebasehelper.helpers.download_helper import DownloadHelper, DownloadError
        """
        Test that progress of a download is shown correctly. Test the case when size parameters are passed as integers.
        """
        buf = io.StringIO()
        monkeypatch.setattr('sys.stdout', buf)
        monkeypatch.setattr('time.time', lambda: 10.0)
        DownloadHelper.progress(total, downloaded, 0.0)
        assert buf.getvalue() == output

    @pytest.mark.parametrize('url, content', [
        ('http://integration:8000/existing_file.txt', 'content'),
        ('https://integration:4430/existing_file.txt', 'content'),
        ('ftp://integration:2100/existing_file.txt', 'content'),
        ('http://integration:8001/existing_file.txt', 'content'),
        ('https://integration:4431/existing_file.txt', 'content'),
        ('ftp://integration:2101/existing_file.txt', 'content'),
    ], ids=[
        'HTTP',
        'HTTPS',
        'FTP',
        'HTTP-unknown_size',
        'HTTPS-unknown_size',
        'FTP-unknown_size',
    ])
    @pytest.mark.integration
    def test_download_existing_file(self, url, content):
        """Test downloading existing file"""
        local_file = 'local_file'
        DownloadHelper.download_file(url, local_file)
        assert os.path.isfile(local_file)

# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()
# 
# Path: rebasehelper/helpers/download_helper.py
# class DownloadHelper:
#         class FTPAdapter(requests.adapters.BaseAdapter):
#     def progress(download_total, downloaded, start_time, show_size=True):
#         def format_time(t):
#         def format_size(s):
#     def request(url, **kwargs):
#             def send(self, request, stream=False, timeout=None, verify=True,  # pylint: disable=unused-argument
#                      cert=None, proxies=None):  # pylint: disable=unused-argument
#             def close(self):
#     def download_file(url, destination_path, blocksize=8192):


# Path: rebasehelper/tests/helpers/test_download_helper.py
import io
import os
import pytest  # type: ignore
from rebasehelper.constants import ENCODING
from rebasehelper.helpers.download_helper import DownloadHelper, DownloadError

        """
        Test that progress of a download is shown correctly. Test the case when size parameters are passed as integers.
        """
        buf = io.StringIO()
        monkeypatch.setattr('sys.stdout', buf)
        monkeypatch.setattr('time.time', lambda: 10.0)
        DownloadHelper.progress(total, downloaded, 0.0)
        assert buf.getvalue() == output

    @pytest.mark.parametrize('url, content', [
        ('http://integration:8000/existing_file.txt', 'content'),
        ('https://integration:4430/existing_file.txt', 'content'),
        ('ftp://integration:2100/existing_file.txt', 'content'),
        ('http://integration:8001/existing_file.txt', 'content'),
        ('https://integration:4431/existing_file.txt', 'content'),
        ('ftp://integration:2101/existing_file.txt', 'content'),
    ], ids=[
        'HTTP',
        'HTTPS',
        'FTP',
        'HTTP-unknown_size',
        'HTTPS-unknown_size',
        'FTP-unknown_size',
    ])
    @pytest.mark.integration
    def test_download_existing_file(self, url, content):
        """Test downloading existing file"""
        local_file = 'local_file'
        DownloadHelper.download_file(url, local_file)
        assert os.path.isfile(local_file)

        with open(local_file, encoding=ENCODING) as f: