# Path: mycroft/util/download.py
# def _get_download_tmp(dest):
#     def __init__(self, url, dest, complete_action=None, header=None):
#     def perform_download(self, dest):
#     def run(self):
#     def finalize(self, tmp):
#     def cleanup(self, tmp):
#     def abort(self):
# def download(url, dest, complete_action=None, header=None):
# class Downloader(Thread):
# 
# Path: mycroft/util/file_utils.py
# def get_temp_path(*args):
#     """Generate a valid path in the system temp directory.
# 
#     This method accepts one or more strings as arguments. The arguments are
#     joined and returned as a complete path inside the systems temp directory.
#     Importantly, this will not create any directories or files.
# 
#     Example usage: get_temp_path('mycroft', 'audio', 'example.wav')
#     Will return the equivalent of: '/tmp/mycroft/audio/example.wav'
# 
#     Args:
#         path_element (str): directories and/or filename
# 
#     Returns:
#         (str) a valid path in the systems temp directory
#     """
#     try:
#         path = os.path.join(tempfile.gettempdir(), *args)
#     except TypeError:
#         raise TypeError("Could not create a temp path, get_temp_path() only "
#                         "accepts Strings")
#     return path


from threading import Event
from unittest import TestCase, mock
from mycroft.util.download import (download, _running_downloads,
                                   _get_download_tmp)
from mycroft.util.file_utils import get_temp_path



TEST_URL = 'http://example.com/mycroft-test.tar.gz'
TEST_DEST = get_temp_path('file.tar.gz')


@mock.patch('mycroft.util.download.subprocess')
@mock.patch('mycroft.util.download.os')
class TestDownload(TestCase):
    def setUp(self):
        """Remove any cached instance."""
        for key in list(_running_downloads.keys()):

# Path: mycroft/util/download.py
# def _get_download_tmp(dest):
#     def __init__(self, url, dest, complete_action=None, header=None):
#     def perform_download(self, dest):
#     def run(self):
#     def finalize(self, tmp):
#     def cleanup(self, tmp):
#     def abort(self):
# def download(url, dest, complete_action=None, header=None):
# class Downloader(Thread):
# 
# Path: mycroft/util/file_utils.py
# def get_temp_path(*args):
#     """Generate a valid path in the system temp directory.
# 
#     This method accepts one or more strings as arguments. The arguments are
#     joined and returned as a complete path inside the systems temp directory.
#     Importantly, this will not create any directories or files.
# 
#     Example usage: get_temp_path('mycroft', 'audio', 'example.wav')
#     Will return the equivalent of: '/tmp/mycroft/audio/example.wav'
# 
#     Args:
#         path_element (str): directories and/or filename
# 
#     Returns:
#         (str) a valid path in the systems temp directory
#     """
#     try:
#         path = os.path.join(tempfile.gettempdir(), *args)
#     except TypeError:
#         raise TypeError("Could not create a temp path, get_temp_path() only "
#                         "accepts Strings")
#     return path


# Path: test/unittests/util/test_download.py
from threading import Event
from unittest import TestCase, mock
from mycroft.util.download import (download, _running_downloads,
                                   _get_download_tmp)
from mycroft.util.file_utils import get_temp_path




TEST_URL = 'http://example.com/mycroft-test.tar.gz'
TEST_DEST = get_temp_path('file.tar.gz')


@mock.patch('mycroft.util.download.subprocess')
@mock.patch('mycroft.util.download.os')
class TestDownload(TestCase):
    def setUp(self):
        """Remove any cached instance."""
        for key in list(_running_downloads.keys()):

            _running_downloads.pop(key)