ordigi/elodie/tests/config_test.py
Terence Eden cd5ba92b0b Support user defined folder structure (#5) (#160)
* Custom date directories
* Add config module to parse ini files
* Add method/tests to get a customizable folder path
* Cache path definition
* Initial working version of custom paths
* Add Directory values in sample config
* Refactoring location parsing logic and adding tests
* Remove unused functions
* Add documentation to parse_mask_for_location
* Remove commented out code
* Add tests for migrating old location db to new
2017-01-02 20:58:52 -08:00

32 lines
1001 B
Python

from __future__ import absolute_import
# Project imports
import os
import sys
import unittest
from mock import patch
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
from elodie import constants
from elodie.config import load_config
BASE_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
@patch('elodie.config.config_file', '%s/config.ini-sample' % BASE_PATH)
def test_load_config_singleton_success():
config = load_config()
assert config['MapQuest']['key'] == 'your-api-key-goes-here', config.get('MapQuest', 'key')
config.set('MapQuest', 'key', 'new-value')
config = load_config()
assert config['MapQuest']['key'] == 'new-value', config.get('MapQuest', 'key')
del load_config.config
@patch('elodie.config.config_file', '%s/config.ini-does-not-exist' % BASE_PATH)
def test_load_config_singleton_no_file():
config = load_config()
assert config == {}, config