# Path: helpers/config.py
# def load_config():
#     """ Load configuration and set debug flag for this environment """
#     
#     # Load global configuration
#     config = yaml.load(open(os.path.abspath('./conf/global.yaml'), 'r').read())
# 
#     # Detect development or production environment and configure accordingly
#     if os.environ['SERVER_SOFTWARE'].startswith('Dev'):
#         conf_f = open(os.path.abspath('./conf/development.yaml'), 'r')
#         config = dict(config.items() + yaml.load(conf_f.read()).items())
#     else:
#         conf_f = open(os.path.abspath('./conf/production.yaml'), 'r')
#         config = dict(config.items() + yaml.load(conf_f.read()).items())
# 
#     return config
# 
# class ConfigurationError(Exception):
#     """ A general configuration exception """
#     def __init__(self, value):
#         self.value = value
# 
#     def __str__(self):
#         return self.value


import os
import unittest
from helpers.config import load_config, ConfigurationError
# -*- coding: utf-8 -*-


class LoadConfigTest(unittest.TestCase):

    def test_development_config(self):
        os.environ['SERVER_SOFTWARE'] = 'Dev-XXX'
        config = load_config()
        self.assertIsInstance(config, dict)
        self.assertTrue(config['debug'])

    def test_production_config(self):
        os.environ['SERVER_SOFTWARE'] = 'Live-XXX'

# Path: helpers/config.py
# def load_config():
#     """ Load configuration and set debug flag for this environment """
#     
#     # Load global configuration
#     config = yaml.load(open(os.path.abspath('./conf/global.yaml'), 'r').read())
# 
#     # Detect development or production environment and configure accordingly
#     if os.environ['SERVER_SOFTWARE'].startswith('Dev'):
#         conf_f = open(os.path.abspath('./conf/development.yaml'), 'r')
#         config = dict(config.items() + yaml.load(conf_f.read()).items())
#     else:
#         conf_f = open(os.path.abspath('./conf/production.yaml'), 'r')
#         config = dict(config.items() + yaml.load(conf_f.read()).items())
# 
#     return config
# 
# class ConfigurationError(Exception):
#     """ A general configuration exception """
#     def __init__(self, value):
#         self.value = value
# 
#     def __str__(self):
#         return self.value


# Path: tests/test_helpers/test_config.py
import os
import unittest
from helpers.config import load_config, ConfigurationError

# -*- coding: utf-8 -*-


class LoadConfigTest(unittest.TestCase):

    def test_development_config(self):
        os.environ['SERVER_SOFTWARE'] = 'Dev-XXX'
        config = load_config()
        self.assertIsInstance(config, dict)
        self.assertTrue(config['debug'])

    def test_production_config(self):
        os.environ['SERVER_SOFTWARE'] = 'Live-XXX'

        config = load_config()