# Path: openelex/config.py
# class Settings(object):
#     """
#     Encapsulate settings and provide utilities for adding settings from
#     elsewhere.
# 
#     The design of this class is heavily influenced by how the Django and Flask
#     frameworks handle configuration.
# 
#     """
#     def from_object(self, obj):
#         """Copy uppercase attributes from another object to this one"""
#         for key in dir(obj):
#             if key.isupper():
#                 val = getattr(obj, key)
#                 setattr(self, key, val)
# 
#         return self
# 
#     def from_module_name(self, name):
#         """
#         Load settings attributes from a Python module
# 
#         Args:
#             name (str): The name of a Python module.
# 
#         """
#         module = import_module(name)
#         return self.from_object(module)
# 
#     def from_file(self, filename):
#         """
#         Load settings from a Python file
# 
#         Args:
#             filename (str): Absolute path to a Python file where settings
#                 variables are defined.
#         """
#         config_mod = imp.new_module('config')
#         execfile(filename, config_mod.__dict__)
#         return self.from_object(config_mod)
# 
#     def from_envvar(self, name):
#         """
#         Load settings from a Python file whose filename is in an environment
#         variable
# 
#         Args:
#             name (str): Environment variable containing the absolute path to
#                 a Python file where settings variables are defined.
#         """
#         return self.from_file(os.environ[name])


import os
import sys
from unittest import TestCase
from openelex.config import Settings


TEST_SETTING_1 = "foo"
TEST_SETTING_2 = "bar"

class TestSettings(TestCase):
    def tearDown(self):
        try:
            os.environ = self.env
        except AttributeError:
            pass

    def _test_object_keys(self, settings_obj):
       self.assertEqual(settings_obj.TEST_SETTING_1, "foo")
       self.assertEqual(settings_obj.TEST_SETTING_2, "bar")

    def _fix_filename(self, filename):
        return filename.replace('.pyc', '.py')

    def test_from_object(self):
        settings = Settings()
        settings.from_object(sys.modules[__name__])
        self._test_object_keys(settings)

    def test_from_module_name(self):
        settings = Settings()
        settings.from_module_name(__name__)
        self._test_object_keys(settings)

    def test_from_file(self):

# Path: openelex/config.py
# class Settings(object):
#     """
#     Encapsulate settings and provide utilities for adding settings from
#     elsewhere.
# 
#     The design of this class is heavily influenced by how the Django and Flask
#     frameworks handle configuration.
# 
#     """
#     def from_object(self, obj):
#         """Copy uppercase attributes from another object to this one"""
#         for key in dir(obj):
#             if key.isupper():
#                 val = getattr(obj, key)
#                 setattr(self, key, val)
# 
#         return self
# 
#     def from_module_name(self, name):
#         """
#         Load settings attributes from a Python module
# 
#         Args:
#             name (str): The name of a Python module.
# 
#         """
#         module = import_module(name)
#         return self.from_object(module)
# 
#     def from_file(self, filename):
#         """
#         Load settings from a Python file
# 
#         Args:
#             filename (str): Absolute path to a Python file where settings
#                 variables are defined.
#         """
#         config_mod = imp.new_module('config')
#         execfile(filename, config_mod.__dict__)
#         return self.from_object(config_mod)
# 
#     def from_envvar(self, name):
#         """
#         Load settings from a Python file whose filename is in an environment
#         variable
# 
#         Args:
#             name (str): Environment variable containing the absolute path to
#                 a Python file where settings variables are defined.
#         """
#         return self.from_file(os.environ[name])


# Path: openelex/tests/test_config.py
import os
import sys
from unittest import TestCase
from openelex.config import Settings



TEST_SETTING_1 = "foo"
TEST_SETTING_2 = "bar"

class TestSettings(TestCase):
    def tearDown(self):
        try:
            os.environ = self.env
        except AttributeError:
            pass

    def _test_object_keys(self, settings_obj):
       self.assertEqual(settings_obj.TEST_SETTING_1, "foo")
       self.assertEqual(settings_obj.TEST_SETTING_2, "bar")

    def _fix_filename(self, filename):
        return filename.replace('.pyc', '.py')

    def test_from_object(self):
        settings = Settings()
        settings.from_object(sys.modules[__name__])
        self._test_object_keys(settings)

    def test_from_module_name(self):
        settings = Settings()
        settings.from_module_name(__name__)
        self._test_object_keys(settings)

    def test_from_file(self):

        settings = Settings()