# Path: elodie/constants.py

# 
# Path: elodie/config.py
# def load_config():
#     if hasattr(load_config, "config"):
#         return load_config.config
# 
#     if not path.exists(config_file):
#         return {}
# 
#     load_config.config = RawConfigParser()
#     load_config.config.read(config_file)
#     return load_config.config
# 
# def load_plugin_config():
#     config = load_config()
# 
#     # If plugins are defined in the config we return them as a list
#     # Else we return an empty list
#     if 'Plugins' in config and 'plugins' in config['Plugins']:
#         return config['Plugins']['plugins'].split(',')
# 
#     return []


import os
import sys
import unittest 
from mock import patch
from tempfile import gettempdir
from elodie import constants
from elodie.config import load_config, load_plugin_config
    assert config['MapQuest']['key'] == 'your-api-key-goes-here', config.get('MapQuest', 'key')
    config.set('MapQuest', 'key', 'new-value')

    config = load_config()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert config['MapQuest']['key'] == 'new-value', config.get('MapQuest', 'key')

@patch('elodie.config.config_file', '%s/config.ini-does-not-exist' % gettempdir())
def test_load_config_singleton_no_file():
    if hasattr(load_config, 'config'):
        del load_config.config

    config = load_config()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert config == {}, config

@patch('elodie.config.config_file', '%s/config.ini-load-plugin-config-unset-backwards-compat' % gettempdir())
def test_load_plugin_config_unset_backwards_compat():
    with open('%s/config.ini-load-plugin-config-unset-backwards-compat' % gettempdir(), 'w') as f:
        f.write("""
        """)
    if hasattr(load_config, 'config'):
        del load_config.config


# Path: elodie/constants.py

# 
# Path: elodie/config.py
# def load_config():
#     if hasattr(load_config, "config"):
#         return load_config.config
# 
#     if not path.exists(config_file):
#         return {}
# 
#     load_config.config = RawConfigParser()
#     load_config.config.read(config_file)
#     return load_config.config
# 
# def load_plugin_config():
#     config = load_config()
# 
#     # If plugins are defined in the config we return them as a list
#     # Else we return an empty list
#     if 'Plugins' in config and 'plugins' in config['Plugins']:
#         return config['Plugins']['plugins'].split(',')
# 
#     return []


# Path: elodie/tests/config_test.py
import os
import sys
import unittest 
from mock import patch
from tempfile import gettempdir
from elodie import constants
from elodie.config import load_config, load_plugin_config

    assert config['MapQuest']['key'] == 'your-api-key-goes-here', config.get('MapQuest', 'key')
    config.set('MapQuest', 'key', 'new-value')

    config = load_config()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert config['MapQuest']['key'] == 'new-value', config.get('MapQuest', 'key')

@patch('elodie.config.config_file', '%s/config.ini-does-not-exist' % gettempdir())
def test_load_config_singleton_no_file():
    if hasattr(load_config, 'config'):
        del load_config.config

    config = load_config()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert config == {}, config

@patch('elodie.config.config_file', '%s/config.ini-load-plugin-config-unset-backwards-compat' % gettempdir())
def test_load_plugin_config_unset_backwards_compat():
    with open('%s/config.ini-load-plugin-config-unset-backwards-compat' % gettempdir(), 'w') as f:
        f.write("""
        """)
    if hasattr(load_config, 'config'):
        del load_config.config


    plugins = load_plugin_config()