def test_config_section(): """Run tests over the testing section of the config file""" from common import config test_config = config.Section('testing') str_test = test_config.get('s') assert str_test == 'abc' assert isinstance(str_test, str) or isinstance(str_test, unicode) int_test = test_config.getint('x') assert isinstance(int_test, int) assert int_test == 1 float_test = test_config.getfloat('f') assert isinstance(float_test, float) assert float_test == -0.05 true_test = test_config.getboolean('bt') assert true_test assert isinstance(true_test, bool) false_test = test_config.getboolean('bf') assert not false_test assert isinstance(false_test, bool) list_test = test_config.getlist('li') assert len(list_test) == 3 assert isinstance(list_test, list)
def test_connect(): """A smoke test for both CredentialManager and DatabaseAccess""" from common import config mysql_config = config.Section('mysql') cred_mgr = credential_manager.CredentialManager( host=mysql_config.get('db_host'), user=mysql_config.get('username'), passwd=mysql_config.get('passwd'), name=mysql_config.get('db_name'), ) dba = DatabaseAccess(cred_mgr) dba.connect() dba.close()
def __init__(self): self.slack_config = config.Section('slack')
""" The data_handler module handles mixing data stored in a local cache with the data we fetch from yahoo finance It uses the config file to decided which cache implementation to use (e.g. MySQL, sqlite3) """ from __future__ import print_function import datetime from common import config, errors, credential_manager from . import downloader CACHE_CONFIG = config.Section('cache') DB_CONFIG = None # TODO: Add a layer of abstraction for db connections try: if CACHE_CONFIG.get('cache-impl') != 'mysql': raise Exception() # pylint: disable=ungrouped-imports, wrong-import-position from common import db_manager as db_mgr DB_CONFIG = config.Section('mysql') except Exception: # pylint: disable=ungrouped-imports, wrong-import-position from common import sqlite_manager as db_mgr DB_CONFIG = config.Section('sqlite') TIME_FMT = '%Y-%m-%d'