# 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)


import os
import tests.common as common
import mediahandler.types.movies as Movies
from re import escape
from tests.common import unittest
from tests.common import MHTestSuite
from tests.test_media import MediaObjectTests
Stripping invalid characters from new path: {f}{title}: Episode V - The Empire Strikes Back (1980)
Stripping invalid characters from new path: {f}{title}: Episode VI - Return of the Jedi (1983)
Stripping invalid characters from new path: {f}{title}: Episode I - The Phantom Menace (1999)
Stripping invalid characters from new path: {f}{title}: Episode II - Attack of the Clones (2002)
Stripping invalid characters from new path: {f}{title}: Episode III - Revenge of the Sith (2005)
Stripping invalid characters from new path: {f}{title}: Episode IV - A New Hope (1977)
Skipped [{five}] because [{f}{title} Episode V - The Empire Strikes Back (1980).avi] already exists
Skipped [{three}] because [{f}{title} Episode VI - Return of the Jedi (1983).avi] already exists
[COPY] Rename [{six}] to [{f}{title} Episode I - The Phantom Menace (1999).avi]
[COPY] Rename [{two}] to [{f}{title} Episode II - Attack of the Clones (2002).avi]
[COPY] Rename [{four}] to [{f}{title} Episode III - Revenge of the Sith (2005).avi]
Skipped [{one}] because [{f}{title} Episode IV - A New Hope (1977).avi] already exists
Processed 6 files
Done ?(?????)?
""".format(one=one, two=two, three=three, four=four, five=five, six=six,
           title=title, f=os.path.join(os.path.sep, self.folder, ''))
        (new_files, skipped) = self.movies._process_output(
            output, self.tmp_file)
        new_expected = [
            f'{title} Episode I - The Phantom Menace (1999)',
            f'{title} Episode II - Attack of the Clones (2002)',
            f'{title} Episode III - Revenge of the Sith (2005)',
        ]
        skip_expected = [os.path.basename(five), os.path.basename(three), os.path.basename(one)]
        self.assertEqual(new_files, new_expected)
        self.assertEqual(skipped, skip_expected)


def suite():
    s = MHTestSuite()

# 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: tests/test_movies.py
import os
import tests.common as common
import mediahandler.types.movies as Movies
from re import escape
from tests.common import unittest
from tests.common import MHTestSuite
from tests.test_media import MediaObjectTests

Stripping invalid characters from new path: {f}{title}: Episode V - The Empire Strikes Back (1980)
Stripping invalid characters from new path: {f}{title}: Episode VI - Return of the Jedi (1983)
Stripping invalid characters from new path: {f}{title}: Episode I - The Phantom Menace (1999)
Stripping invalid characters from new path: {f}{title}: Episode II - Attack of the Clones (2002)
Stripping invalid characters from new path: {f}{title}: Episode III - Revenge of the Sith (2005)
Stripping invalid characters from new path: {f}{title}: Episode IV - A New Hope (1977)
Skipped [{five}] because [{f}{title} Episode V - The Empire Strikes Back (1980).avi] already exists
Skipped [{three}] because [{f}{title} Episode VI - Return of the Jedi (1983).avi] already exists
[COPY] Rename [{six}] to [{f}{title} Episode I - The Phantom Menace (1999).avi]
[COPY] Rename [{two}] to [{f}{title} Episode II - Attack of the Clones (2002).avi]
[COPY] Rename [{four}] to [{f}{title} Episode III - Revenge of the Sith (2005).avi]
Skipped [{one}] because [{f}{title} Episode IV - A New Hope (1977).avi] already exists
Processed 6 files
Done ?(?????)?
""".format(one=one, two=two, three=three, four=four, five=five, six=six,
           title=title, f=os.path.join(os.path.sep, self.folder, ''))
        (new_files, skipped) = self.movies._process_output(
            output, self.tmp_file)
        new_expected = [
            f'{title} Episode I - The Phantom Menace (1999)',
            f'{title} Episode II - Attack of the Clones (2002)',
            f'{title} Episode III - Revenge of the Sith (2005)',
        ]
        skip_expected = [os.path.basename(five), os.path.basename(three), os.path.basename(one)]
        self.assertEqual(new_files, new_expected)
        self.assertEqual(skipped, skip_expected)


def suite():
    s = MHTestSuite()

    tests = unittest.TestLoader().loadTestsFromName(__name__)