# Path: tests/common.py
# class MHTestSuite(unittest.TestSuite):
#     def setUpSuite(self):
#     def tearDownSuite(self):
#     def run(self, result):
# def skip_unless_has_mod(module, submodule):
# def get_test_id(size=4):
# def random_string(size=5):
# def temp_file(name=None):
# def make_tmp_file(text=None, tdir=None):
# def get_conf_file():
# def get_orig_settings():
# def get_settings(conf=None):
# def get_types_by_string():
# def get_types_by_id():
# def get_pushover_api():
# def get_pushbullet_api():
# def get_google_api():
# def remove_file(file_path):
# 
# Path: tests/common.py
# class MHTestSuite(unittest.TestSuite):
# 
#     def setUpSuite(self):
#         # Back up current config
#         curr_config = get_conf_file()
#         backup = '{0}.orig'.format(curr_config)
#         if not os.path.exists(backup):
#             shutil.move(curr_config, backup)
#         # Make new config for testing
#         Config.make_config()
# 
#     def tearDownSuite(self):
#         # Restore original config
#         curr_config = get_conf_file()
#         backup = '{0}.orig'.format(curr_config)
#         if os.path.exists(backup):
#             shutil.move(backup, curr_config)
# 
#     def run(self, result):
#         # Before tests
#         self.setUpSuite()
#         # Set buffering
#         result.buffer = True
#         # Run tests
#         super(MHTestSuite, self).run(result)
#         # After tests
#         self.tearDownSuite()
# 
# Path: tests/test_media.py
# class MediaObjectTests(unittest.TestCase):
# 
#     def setUp(self):
#         # Conf
#         self.conf = common.get_conf_file()
#         # Set up push object
#         self.push = Notify.MHPush({
#             'enabled': False,
#             'notify_name': '',
#             'pushover':{
#                 'api_key': common.random_string(),
#                 'user_key': common.random_string(),
#             },
#         }, True)
#         # Make temp stuff
#         self.folder = tempfile.mkdtemp(
#             dir=os.path.dirname(self.conf))
#         self.tmp_file = common.make_tmp_file('.avi')
#         # Build base settings
#         self.settings = common.get_settings()['TV']
#         self.settings['folder'] = self.folder
# 
#     def tearDown(self):
#         if os.path.exists(self.folder):
#             shutil.rmtree(self.folder)
#         if os.path.exists(self.tmp_file):
#             os.unlink(self.tmp_file)
# 
# Path: mediahandler/util/config.py
# def _find_app(settings, app):
#     """Looks for an installed application in the user's local $PATH.
# 
#     Raises an ImportError if the application is not found.
#     """
# 
#     # Save in settings
#     name = app['name'].lower()
#     settings[name] = None
# 
#     # Retrieve local paths
#     split_token = ';' if mh.__iswin__ else ':'
#     local_paths = os.environ['PATH'].rsplit(split_token)
# 
#     # Look for app in local paths
#     for local_path in local_paths:
#         path = os.path.join(local_path, app['exec'])
# 
#         # If the path exists, store & exit the loop
#         if os.path.isfile(path):
#             settings[name] = path
#             break
# 
#         # Try .exe for windows
#         if mh.__iswin__:
#             win_path = path + '.exe'
#             if os.path.isfile(win_path):
#                 settings[name] = win_path
#                 break
# 
#     # If app not found, raise ImportError
#     if settings[name] is None:
#         error = '{0} application not found'.format(app['name'])
#         raise ImportError(error)


import os
import shutil
import tests.common as common
import mediahandler.types.music as Music
from re import escape
from tests.common import unittest
from tests.common import MHTestSuite
from tests.test_media import MediaObjectTests
from mediahandler.util.config import _find_app
    http://musicbrainz.org/release/4186b65f-c36d-4dac-82d3-221d3f8c7925
(Similarity: 100.0%) (2005, US)

/Downloaded/Music/Eisley - Discographie (2002-2012)/Eisley - (2009) Fire Kite EP (1 items)
Skipping.
"""
        (new_file, skipped) = self.tracks._process_output(output, self.tmp_file)
        new_expected = ['Eisley - Room Noises']
        skip_expected = [
            'Eisley - (2003) Marvelous Things EP',
            'Eisley - (2009) Fire Kite EP',
        ]
        self.assertEqual(new_file, new_expected)
        self.assertEqual(skipped, skip_expected)

    def test_music_output_single_skipped(self):
        # Single file
        self.settings['single_track'] = True
        self.tracks = Music.MHMusic(self.settings, self.push)
        output = """
/Downloaded/Music/Taylor Swift - Blank Space {2014-Single} (1 items)
Skipping.
"""
        (new_file, skipped) = self.tracks._process_output(output, self.tmp_file)
        expected = ['Taylor Swift - Blank Space {2014-Single}']
        self.assertEqual(new_file, [])
        self.assertEqual(skipped, expected)


def suite():

# Path: tests/common.py
# class MHTestSuite(unittest.TestSuite):
#     def setUpSuite(self):
#     def tearDownSuite(self):
#     def run(self, result):
# def skip_unless_has_mod(module, submodule):
# def get_test_id(size=4):
# def random_string(size=5):
# def temp_file(name=None):
# def make_tmp_file(text=None, tdir=None):
# def get_conf_file():
# def get_orig_settings():
# def get_settings(conf=None):
# def get_types_by_string():
# def get_types_by_id():
# def get_pushover_api():
# def get_pushbullet_api():
# def get_google_api():
# def remove_file(file_path):
# 
# Path: tests/common.py
# class MHTestSuite(unittest.TestSuite):
# 
#     def setUpSuite(self):
#         # Back up current config
#         curr_config = get_conf_file()
#         backup = '{0}.orig'.format(curr_config)
#         if not os.path.exists(backup):
#             shutil.move(curr_config, backup)
#         # Make new config for testing
#         Config.make_config()
# 
#     def tearDownSuite(self):
#         # Restore original config
#         curr_config = get_conf_file()
#         backup = '{0}.orig'.format(curr_config)
#         if os.path.exists(backup):
#             shutil.move(backup, curr_config)
# 
#     def run(self, result):
#         # Before tests
#         self.setUpSuite()
#         # Set buffering
#         result.buffer = True
#         # Run tests
#         super(MHTestSuite, self).run(result)
#         # After tests
#         self.tearDownSuite()
# 
# Path: tests/test_media.py
# class MediaObjectTests(unittest.TestCase):
# 
#     def setUp(self):
#         # Conf
#         self.conf = common.get_conf_file()
#         # Set up push object
#         self.push = Notify.MHPush({
#             'enabled': False,
#             'notify_name': '',
#             'pushover':{
#                 'api_key': common.random_string(),
#                 'user_key': common.random_string(),
#             },
#         }, True)
#         # Make temp stuff
#         self.folder = tempfile.mkdtemp(
#             dir=os.path.dirname(self.conf))
#         self.tmp_file = common.make_tmp_file('.avi')
#         # Build base settings
#         self.settings = common.get_settings()['TV']
#         self.settings['folder'] = self.folder
# 
#     def tearDown(self):
#         if os.path.exists(self.folder):
#             shutil.rmtree(self.folder)
#         if os.path.exists(self.tmp_file):
#             os.unlink(self.tmp_file)
# 
# Path: mediahandler/util/config.py
# def _find_app(settings, app):
#     """Looks for an installed application in the user's local $PATH.
# 
#     Raises an ImportError if the application is not found.
#     """
# 
#     # Save in settings
#     name = app['name'].lower()
#     settings[name] = None
# 
#     # Retrieve local paths
#     split_token = ';' if mh.__iswin__ else ':'
#     local_paths = os.environ['PATH'].rsplit(split_token)
# 
#     # Look for app in local paths
#     for local_path in local_paths:
#         path = os.path.join(local_path, app['exec'])
# 
#         # If the path exists, store & exit the loop
#         if os.path.isfile(path):
#             settings[name] = path
#             break
# 
#         # Try .exe for windows
#         if mh.__iswin__:
#             win_path = path + '.exe'
#             if os.path.isfile(win_path):
#                 settings[name] = win_path
#                 break
# 
#     # If app not found, raise ImportError
#     if settings[name] is None:
#         error = '{0} application not found'.format(app['name'])
#         raise ImportError(error)


# Path: tests/test_music.py
import os
import shutil
import tests.common as common
import mediahandler.types.music as Music
from re import escape
from tests.common import unittest
from tests.common import MHTestSuite
from tests.test_media import MediaObjectTests
from mediahandler.util.config import _find_app

    http://musicbrainz.org/release/4186b65f-c36d-4dac-82d3-221d3f8c7925
(Similarity: 100.0%) (2005, US)

/Downloaded/Music/Eisley - Discographie (2002-2012)/Eisley - (2009) Fire Kite EP (1 items)
Skipping.
"""
        (new_file, skipped) = self.tracks._process_output(output, self.tmp_file)
        new_expected = ['Eisley - Room Noises']
        skip_expected = [
            'Eisley - (2003) Marvelous Things EP',
            'Eisley - (2009) Fire Kite EP',
        ]
        self.assertEqual(new_file, new_expected)
        self.assertEqual(skipped, skip_expected)

    def test_music_output_single_skipped(self):
        # Single file
        self.settings['single_track'] = True
        self.tracks = Music.MHMusic(self.settings, self.push)
        output = """
/Downloaded/Music/Taylor Swift - Blank Space {2014-Single} (1 items)
Skipping.
"""
        (new_file, skipped) = self.tracks._process_output(output, self.tmp_file)
        expected = ['Taylor Swift - Blank Space {2014-Single}']
        self.assertEqual(new_file, [])
        self.assertEqual(skipped, expected)


def suite():

    s = MHTestSuite()