Changeset - 18f7ea7038d3
[Not reviewed]
0 2 0
Brett Smith - 7 years ago 2017-05-17 16:29:50
brettcsmith@brettcsmith.org
Configuration: Set up CacheWriter.
2 files changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
oxrlib/config.py
Show inline comments
...
 
@@ -2,13 +2,13 @@ import argparse
 
import configparser
 
import datetime
 
import decimal
 
import os.path
 
import pathlib
 

	
 
from . import loaders
 
from . import cache, loaders
 

	
 
HOME_PATH = pathlib.Path(os.path.expanduser('~'))
 
CONFFILE_SEED = """
 
[Historical]
 
base=USD
 
"""
...
 
@@ -124,12 +124,13 @@ class Configuration:
 
    def _build_cache_loader(self):
 
        kwargs = dict(self.conffile.items('Cache'))
 
        try:
 
            kwargs['dir_path'] = kwargs.pop('directory')
 
        except KeyError:
 
            pass
 
        self.cache = cache.CacheWriter(**kwargs)
 
        return loaders.FileCache(**kwargs)
 

	
 
    def _build_oxrapi_loader(self):
 
        kwargs = dict(self.conffile.items('OXR'))
 
        return loaders.OXRAPIRequest(**kwargs)
 

	
tests/test_Configuration.py
Show inline comments
...
 
@@ -2,12 +2,13 @@ import decimal
 
import os
 

	
 
import pytest
 

	
 
from . import any_date, relpath
 

	
 
import oxrlib.cache
 
import oxrlib.config
 
import oxrlib.loaders
 

	
 
INI_DIR_PATH = relpath('config_ini')
 

	
 
def config_from(ini_filename, arglist=None):
...
 
@@ -19,12 +20,13 @@ def config_from(ini_filename, arglist=None):
 
def test_full_config():
 
    config = config_from('full.ini')
 
    loaders = config.get_loaders().loaders
 
    assert type(loaders[0]) is oxrlib.loaders.FileCache
 
    assert type(loaders[1]) is oxrlib.loaders.OXRAPIRequest
 
    assert len(loaders) == 2
 
    assert type(config.cache) is oxrlib.cache.CacheWriter
 

	
 
def test_incomplete_config():
 
    config = config_from('incomplete.ini')
 
    assert not config.get_loaders().loaders
 

	
 
def test_empty_config():
0 comments (0 inline, 0 general)