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


import os
import re
import sys
import shutil
import yaml
import tests.common as common
import mediahandler.util.config as Config
from tests.common import unittest
from tests.common import tempfile
from tests.common import MHTestSuite
    from pwd import getpwuid
        self.new_conf = os.path.join(conf_dir, 'temp_FVCT.yml')
        # Copy into temp file
        shutil.copy(self.conf, self.new_conf)
        # Placholders
        self.tmp_file = ''
        self.dir = ''

    def tearDown(self):
        common.remove_file(self.new_conf)
        if os.path.exists(self.tmp_file):
            common.remove_file(self.tmp_file)
        if os.path.exists(self.dir):
            shutil.rmtree(self.dir)

    def test_valid_file(self):
        self.tmp_file = common.make_tmp_file('.log')
        # Empty string case
        file_null = Config._get_valid_file('Deluge', 'user', None)
        self.assertIsNone(file_null)
        # Valid case
        file_good = Config._get_valid_file('Music', 'log_file', self.tmp_file)
        self.assertEqual(file_good, self.tmp_file)
        # Invalid case
        log_file = os.path.join('path', 'to', 'log.log')
        regex = "File path provided for 'Logging: log_file' does not exist:"
        self.assertRaisesRegexp(
            ValueError, regex,
            Config._get_valid_file, 'Logging', 'log_file', log_file)

    def test_valid_folder(self):

# 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):
#     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_config.py
import os
import re
import sys
import shutil
import yaml
import tests.common as common
import mediahandler.util.config as Config
from tests.common import unittest
from tests.common import tempfile
from tests.common import MHTestSuite
    from pwd import getpwuid

        self.new_conf = os.path.join(conf_dir, 'temp_FVCT.yml')
        # Copy into temp file
        shutil.copy(self.conf, self.new_conf)
        # Placholders
        self.tmp_file = ''
        self.dir = ''

    def tearDown(self):
        common.remove_file(self.new_conf)
        if os.path.exists(self.tmp_file):
            common.remove_file(self.tmp_file)
        if os.path.exists(self.dir):
            shutil.rmtree(self.dir)

    def test_valid_file(self):
        self.tmp_file = common.make_tmp_file('.log')
        # Empty string case
        file_null = Config._get_valid_file('Deluge', 'user', None)
        self.assertIsNone(file_null)
        # Valid case
        file_good = Config._get_valid_file('Music', 'log_file', self.tmp_file)
        self.assertEqual(file_good, self.tmp_file)
        # Invalid case
        log_file = os.path.join('path', 'to', 'log.log')
        regex = "File path provided for 'Logging: log_file' does not exist:"
        self.assertRaisesRegexp(
            ValueError, regex,
            Config._get_valid_file, 'Logging', 'log_file', log_file)

    def test_valid_folder(self):

        self.dir = self.dir = tempfile.mkdtemp(