# Path: gap/conf.py
#     DEFAULT_SETTINGS = {}
#     KEY = 'app_settings'
# class AppSettings(ndb.Expando):
# class LazyAppSettings(object):
# class SettingsDict(object):
#     def get_key(cls):
#     def put(self, *args, **kwargs):
#     def get_uuid(cls):
#     def set_uuid(cls):
#     def __get__(self, instance, owner=None):
#     def _set_settings(self, dict_data):
#     def __getitem__(self, key):
#                 def new_setter(obj, key, value):
#     def __setitem__(self, key, value):
#     def add_setting(self, key, value):
#     def save(self):
#     def reload(self):
#     def del_setting(self, key):
#     def __hasitem__(self, key):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def values(self):
#     def __iter__(self):
# 
# Path: gap/utils/tests.py
# class TestBase(TestCase):
# 
#     testbed = None
# 
#     _gae_stubs = setup.DEFAULT_TESTBEDS
# 
#     # Allow to share the setUpClass method among all parallel test classes
#     _multiprocess_shared_ = True
# 
#     # Allow concurrent run of fixtures
#     _multiprocess_can_split_ = True
# 
#     @classmethod
#     def setUpClass(cls):
#         # Begin with testbed instance
#         cls.testbed = setup.setup_testbed(stubs=cls._gae_stubs)
#         import app
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.testbed.deactivate()
# 
#     @staticmethod
#     def login(email, admin=False, user_id=None):
#         from os import environ as env
#         env['USER_EMAIL'] = email
#         env['USER_ID'] = user_id if user_id is not None else ''
#         env['USER_IS_ADMIN'] = str(int(admin))
#         # env = getattr(self, 'env', {})
#         # self.env = env
# 
#     @staticmethod
#     def logout():
#         from os import environ as env
#         for name in 'USER_EMAIL', 'USER_ID', 'USER_IS_ADMIN':
#             env[name] = ''


from gap.conf import settings
from gap.utils.tests import TestBase
        from gap import conf
        from google.appengine.api import namespace_manager
    '''gap.conf.settings'''

    def test_initial_settings_value(self):
        """settings['version'] is not None"""
        self.assertIsNotNone(settings['version'])

    def test_store_settings_value(self):
        """settings returns stored value"""
        settings['version'] = '1'
        self.assertEqual(settings['version'], '1')

    def test_read_not_existing_settings_value(self):
        """settings reading non-existing key raises KeyError"""

        def set_key(key, value):
            settings[key] = value

        self.assertRaises(KeyError, lambda x: x['non_existing_key'], settings)
        self.assertRaises(KeyError, set_key, 'non_existing_key', 1)

    def test_add_setting(self):
        '''settings - new setting can be added and removed'''
        self.assertRaises(KeyError, lambda: settings['new_property'])
        settings.add_setting('new_property', 255)
        self.assertEqual(settings['new_property'], 255)
        settings.del_setting('new_property')
        self.assertRaises(KeyError, lambda: settings['new_property'])

    def test_composed_setting(self):
        '''settings - structured value save settings when changed'''

# Path: gap/conf.py
#     DEFAULT_SETTINGS = {}
#     KEY = 'app_settings'
# class AppSettings(ndb.Expando):
# class LazyAppSettings(object):
# class SettingsDict(object):
#     def get_key(cls):
#     def put(self, *args, **kwargs):
#     def get_uuid(cls):
#     def set_uuid(cls):
#     def __get__(self, instance, owner=None):
#     def _set_settings(self, dict_data):
#     def __getitem__(self, key):
#                 def new_setter(obj, key, value):
#     def __setitem__(self, key, value):
#     def add_setting(self, key, value):
#     def save(self):
#     def reload(self):
#     def del_setting(self, key):
#     def __hasitem__(self, key):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def values(self):
#     def __iter__(self):
# 
# Path: gap/utils/tests.py
# class TestBase(TestCase):
# 
#     testbed = None
# 
#     _gae_stubs = setup.DEFAULT_TESTBEDS
# 
#     # Allow to share the setUpClass method among all parallel test classes
#     _multiprocess_shared_ = True
# 
#     # Allow concurrent run of fixtures
#     _multiprocess_can_split_ = True
# 
#     @classmethod
#     def setUpClass(cls):
#         # Begin with testbed instance
#         cls.testbed = setup.setup_testbed(stubs=cls._gae_stubs)
#         import app
# 
#     @classmethod
#     def tearDownClass(cls):
#         cls.testbed.deactivate()
# 
#     @staticmethod
#     def login(email, admin=False, user_id=None):
#         from os import environ as env
#         env['USER_EMAIL'] = email
#         env['USER_ID'] = user_id if user_id is not None else ''
#         env['USER_IS_ADMIN'] = str(int(admin))
#         # env = getattr(self, 'env', {})
#         # self.env = env
# 
#     @staticmethod
#     def logout():
#         from os import environ as env
#         for name in 'USER_EMAIL', 'USER_ID', 'USER_IS_ADMIN':
#             env[name] = ''


# Path: gap/tests/test_settings.py
from gap.conf import settings
from gap.utils.tests import TestBase
        from gap import conf
        from google.appengine.api import namespace_manager

    '''gap.conf.settings'''

    def test_initial_settings_value(self):
        """settings['version'] is not None"""
        self.assertIsNotNone(settings['version'])

    def test_store_settings_value(self):
        """settings returns stored value"""
        settings['version'] = '1'
        self.assertEqual(settings['version'], '1')

    def test_read_not_existing_settings_value(self):
        """settings reading non-existing key raises KeyError"""

        def set_key(key, value):
            settings[key] = value

        self.assertRaises(KeyError, lambda x: x['non_existing_key'], settings)
        self.assertRaises(KeyError, set_key, 'non_existing_key', 1)

    def test_add_setting(self):
        '''settings - new setting can be added and removed'''
        self.assertRaises(KeyError, lambda: settings['new_property'])
        settings.add_setting('new_property', 255)
        self.assertEqual(settings['new_property'], 255)
        settings.del_setting('new_property')
        self.assertRaises(KeyError, lambda: settings['new_property'])

    def test_composed_setting(self):
        '''settings - structured value save settings when changed'''

        settings.add_setting('test', {'a': 1})