def setUp(self): def builder(cls): return self.builder_mock.build(cls) self.builder_mock = mock() def processing_task_factory(instance, deps, lookback): return self.processing_task_factory_mock.create(instance) self.processing_task_factory_mock = mock() self.engine = core.DatasourceEngine(builder, processing_task_factory) class _Task(object): def __init__(self, instance): self.instance = instance self.instances = [] self.classes = [] for i in range(3): @self.engine.datasource('REGISTERED_KEY_%i' % i) class _SampleDatasource(object): pass instance = _SampleDatasource() self.classes.append(_SampleDatasource) self.instances.append(instance) when(self.builder_mock).build(_SampleDatasource).thenReturn( instance) when( self.processing_task_factory_mock).create(instance).thenReturn( _Task(instance))
def setUp(self): self.TagManager = core.tagselection.TagManager self.tagManagerMock = mock(core.tagselection.TagManager) when(self.tagManagerMock).__call__(anyx(dict)).thenReturn( self.tagManagerMock) core.tagselection.TagManager = utils.CallableMock(self.tagManagerMock) self.engine = core.DatasourceEngine()
def setUp(self): self.TagSelector = core.tagselection.TagSelector self.tagSelectorMock = mock(core.tagselection.TagSelector) core.tagselection.TagSelector = utils.CallableMock( self.tagSelectorMock) when(self.tagSelectorMock).__call__(anyx()).thenReturn( self.tagSelectorMock) self.TagManager = core.tagselection.TagManager self.tagManagerMock = mock(core.tagselection.TagManager) core.tagselection.TagManager = utils.CallableMock(self.tagManagerMock) when(self.tagManagerMock).__call__(anyx()).thenReturn( self.tagManagerMock) when(self.tagManagerMock).infere_tags(anyx()).thenReturn(set()) self.engine = core.DatasourceEngine()
# -*- coding: utf-8 -*- import os import sys import pandas import datetime import bigtempo.core as core import bigtempo.auditor as auditor dt = datetime.datetime cities = ['CITY_A', 'CITY_B'] engine = core.DatasourceEngine() def _get_test_data_dir(): return os.path.abspath(os.path.join('tests', 'acceptance_tests_data')) def _get_test_data_filename(reference, symbol=None): symbol_part = '' if not symbol else '{%s}' % symbol return '%s%s.csv' % (reference, symbol_part) def _get_test_data_filepath(reference, symbol=None): return os.path.join(_get_test_data_dir(), _get_test_data_filename(reference, symbol)) @engine.datasource('SAMPLE', tags=['SAMPLE_IN', 'DAILY'], frequency='B') class Sample(object): def evaluate(self, context, symbol, start=None, end=None):
def setUp(self): self.engine = core.DatasourceEngine() _create_test_scenario(self.engine)