# Path: configmanager/sections.py
# class PathProxy(object):
#     def __init__(self, config, path):
#         self.__path_getter = functools.partial(config._get_item_or_section, path)
#         self.__path_target = not_set
# 
#     def _get_real_object(self):
#         if self.__path_target is not_set:
#             self.__path_target = self.__path_getter()
#         return self.__path_target
# 
#     def __getattr__(self, name):
#         return getattr(self._get_real_object(), name)


from configmanager.sections import PathProxy


def test_path_proxy_class(simple_config):
    enabled = PathProxy(simple_config, ('uploads', 'enabled'))
    assert enabled.value is False

    nonexistent_path = ('uploads', 'something', 'nonexistent')
    assert nonexistent_path not in simple_config


# Path: configmanager/sections.py
# class PathProxy(object):
#     def __init__(self, config, path):
#         self.__path_getter = functools.partial(config._get_item_or_section, path)
#         self.__path_target = not_set
# 
#     def _get_real_object(self):
#         if self.__path_target is not_set:
#             self.__path_target = self.__path_getter()
#         return self.__path_target
# 
#     def __getattr__(self, name):
#         return getattr(self._get_real_object(), name)


# Path: tests/test_proxies.py
from configmanager.sections import PathProxy



def test_path_proxy_class(simple_config):
    enabled = PathProxy(simple_config, ('uploads', 'enabled'))
    assert enabled.value is False

    nonexistent_path = ('uploads', 'something', 'nonexistent')
    assert nonexistent_path not in simple_config


    nonexistent = PathProxy(simple_config, nonexistent_path)