def test_validate_reverse_split(self): """run split as intended, old item with new data""" if platform.system() == 'Darwin': pytest.xfail('Unable to run fbprophet on mac') test_clear_caches() assert TEST_API_KEY != '' # vv FIXME vv: depends on split_utils package api_utils.SPLIT_INFO = split_utils.read_split_info() api_utils.SPLIT_INFO[self.demosplit_obj.type_id] = self.demosplit_obj # ^^ FIXME ^^ # req = self.client.get( url_for('prophetendpoint', return_type='csv') + '?typeID={type_id}®ionID={region_id}&api={api_key}&range={range}' .format(type_id=self.demosplit_obj.original_id, region_id=CONFIG.get('TEST', 'region_id'), api_key=TEST_API_KEY, range=CONFIG.get('TEST', 'forecast_range'))) data = None with io.StringIO(req.data.decode()) as buff: data = pd.read_csv(buff) assert req._status_code == 200
def test_load_data(): """push data into global scope for testing""" api_utils.SPLIT_INFO = split_utils.read_split_info() demosplit_obj = split_utils.SplitInfo(DEMO_SPLIT) revrsplit_obj = split_utils.SplitInfo(DEMO_UNSPLIT) api_utils.SPLIT_INFO[demosplit_obj.type_id] = demosplit_obj api_utils.SPLIT_INFO[revrsplit_obj.type_id] = revrsplit_obj
def create_app( settings=None, local_configs=None, testmode=False, ): """create Flask application (ROOT) Modeled from: https://github.com/yabb85/ueki/blob/master/ueki/__init__.py Args: settings (:obj:`dict`, optional): collection of Flask options local_configs (:obj:`configparser.ConfigParser` optional): app private configs testmode (bool): pytest hook """ from flask import Flask import publicAPI.crest_endpoint as crest_endpoint import publicAPI.config as config import publicAPI.split_utils as split_utils import prosper.common.prosper_logging as p_logging app = Flask(__name__) if settings: app.config.update(settings) crest_endpoint.API.init_app(app) crest_endpoint.APP_HACK = app if not testmode: log_builder = p_logging.ProsperLogger( 'publicAPI', local_configs.get_option('LOGGING', 'log_path'), local_configs ) if app.debug or testmode: log_builder.configure_debug_logger() else: log_builder.configure_discord_logger() if log_builder: for handle in log_builder: app.logger.addHandler(handle) config.LOGGER = log_builder.get_logger() else: config.LOGGER = logging.getLogger('publicAPI') config.CONFIG = local_configs config.load_globals(local_configs) crest_endpoint.LOGGER = app.logger config.SPLIT_INFO = split_utils.read_split_info(logger=crest_endpoint.LOGGER) return app
def test_validate_reverse_split(self): """run split normally, old item with forward data""" # vv FIXME vv: depends on split_utils package api_utils.SPLIT_INFO = split_utils.read_split_info() api_utils.SPLIT_INFO[self.demosplit_obj.type_id] = self.demosplit_obj # ^^ FIXME ^^ # req = self.client.get( url_for('ohlc_endpoint', return_type='csv') + '?typeID={type_id}®ionID={region_id}'.format( type_id=self.demosplit_obj.original_id, #type_id=CONFIG.get('TEST', 'type_id'), region_id=CONFIG.get('TEST', 'region_id'))) data = None with io.StringIO(req.data.decode()) as buff: data = pd.read_csv(buff) assert req._status_code == 200
def create_app( settings=None, local_configs=None, ): """create Flask application (ROOT) Modeled from: https://github.com/yabb85/ueki/blob/master/ueki/__init__.py Args: settings (:obj:`dict`, optional): collection of Flask options local_configs (:obj:`configparser.ConfigParser` optional): app private configs log_builder (:obj:`prosper_config.ProsperLogger`, optional): logging container """ app = Flask(__name__) if settings: app.config.update(settings) crest_endpoint.API.init_app(app) crest_endpoint.APP_HACK = app log_builder = p_logging.ProsperLogger('publicAPI', '/var/log/prosper/', local_configs) if not app.debug: log_builder.configure_discord_logger() else: log_builder.configure_debug_logger() if log_builder: for handle in log_builder: app.logger.addHandler(handle) config.LOGGER = log_builder.get_logger() config.CONFIG = local_configs config.load_globals(local_configs) crest_endpoint.LOGGER = app.logger config.SPLIT_INFO = split_utils.read_split_info( logger=crest_endpoint.LOGGER) return app