# Path: ejtp/tests/resource_path.py
# def testing_path(path):
#     return os.path.join(
#         os.path.dirname(os.path.abspath(__file__)),
#         path
#     )
# 
# Path: ejtp/util/compat.py

# 
# Path: ejtp/config.py
# def test_filenames(filenames, env_var=None):
# def configure_identity_cache(cache, filenames=['~/.ejtp/idents.json', '~/.ejtp/console/idents.json']):
# def configure_ejtpd(filenames):


import os
from ejtp.tests.resource_path import testing_path
from ejtp.util.compat import unittest
from ejtp import config
        from ejtp.identity.cache import IdentityCache


class TestConfig(unittest.TestCase):

    config_file = testing_path('examplecache.json')

    def test_test_filenames(self):
        self.assertEqual([self.config_file],
            config.test_filenames([self.config_file, 'some/invalid/file.json']))

    def test_test_filenames_env_var(self):
        os.environ['SOME_PATH'] = self.config_file + ':another/invalid/file.json'
        self.assertEqual([self.config_file],
            config.test_filenames(['some/invalid/file.json'], env_var='SOME_PATH'))

    def test_configure_identity_cache(self):
        cache = IdentityCache()

        # Clear environment variable
        key = 'EJTP_IDENTITY_CACHE_PATH'
        if key in os.environ:
            del os.environ[key]


# Path: ejtp/tests/resource_path.py
# def testing_path(path):
#     return os.path.join(
#         os.path.dirname(os.path.abspath(__file__)),
#         path
#     )
# 
# Path: ejtp/util/compat.py

# 
# Path: ejtp/config.py
# def test_filenames(filenames, env_var=None):
# def configure_identity_cache(cache, filenames=['~/.ejtp/idents.json', '~/.ejtp/console/idents.json']):
# def configure_ejtpd(filenames):


# Path: ejtp/tests/test_config.py
import os
from ejtp.tests.resource_path import testing_path
from ejtp.util.compat import unittest
from ejtp import config
        from ejtp.identity.cache import IdentityCache



class TestConfig(unittest.TestCase):

    config_file = testing_path('examplecache.json')

    def test_test_filenames(self):
        self.assertEqual([self.config_file],
            config.test_filenames([self.config_file, 'some/invalid/file.json']))

    def test_test_filenames_env_var(self):
        os.environ['SOME_PATH'] = self.config_file + ':another/invalid/file.json'
        self.assertEqual([self.config_file],
            config.test_filenames(['some/invalid/file.json'], env_var='SOME_PATH'))

    def test_configure_identity_cache(self):
        cache = IdentityCache()

        # Clear environment variable
        key = 'EJTP_IDENTITY_CACHE_PATH'
        if key in os.environ:
            del os.environ[key]


        filenames = config.configure_identity_cache(cache, [self.config_file])