def get_pricing_test_data(self, test_name=None): """get_pricing_test_data""" test_data = api_requests.build_cache_ready_pricing_dataset() if test_name: test_data['_TEST_NAME'] = test_name else: test_data['_TEST_NAME'] = 'not-set' return test_data
def __init__(self, symbol='SPY'): """__init__ :param symbol: ticker """ mock_cache_data = build_cache_ready_pricing_dataset(label='ticker') self.symbol = symbol self.quotes_data = mock_cache_data['pricing'] self.news_data = mock_cache_data['news'] self.options_data = mock_cache_data['options']
def mock_get_options(ticker=None, contract_type=None, exp_date_str=None, strike=None): """mock_get_options :param ticker: ticker to lookup :param exp_date_str: ``YYYY-MM-DD`` expiration date format :param strike: optional strike price, ``None`` returns all option chains :param contract_type: ``C`` calls or ``P`` for puts, if ``strike=None`` then the ``contract_type`` is ignored """ mock_cache_data = build_cache_ready_pricing_dataset(label='ticker') options_data = os.getenv('TEST_OPTIONS', mock_cache_data['options']) return options_data
def mock_extract_news_from_redis_success(label, host, port, db, password, key, **kwargs): """mock_extract_news_from_redis_success :param label: test label :param address: test address :param db: test db :param key: test key :param kwargs: additional keyword args as a dictionary """ sample_record = build_cache_ready_pricing_dataset( label=('{}.{}.{}.{}.{}.' 'mock_extract_news_from_redis_success'.format( label, host, port, db, key))) rec = {'data': sample_record['news']} res = build_result(status=SUCCESS, err=None, rec=rec) return res
def mock_extract_news_from_redis_success(label, host, port, db, password, key, **kwargs): """mock_extract_news_from_redis_success :param label: test label :param address: test address :param db: test db :param key: test key :param kwargs: additional keyword args as a dictionary """ sample_record = api_requests.build_cache_ready_pricing_dataset( label=(f'{label}.{host}.{port}.{db}.{key}.' 'mock_extract_news_from_redis_success')) rec = {'data': sample_record['news']} res = build_result.build_result(status=ae_consts.SUCCESS, err=None, rec=rec) return res
def mock_s3_read_contents_from_key(s3, s3_bucket_name, s3_key, encoding='utf-8', convert_as_json=True): """mock_s3_read_contents_from_key Download the S3 key contents as a string. This will raise exceptions. :param s3_obj: existing S3 object :param s3_bucket_name: bucket name :param s3_key: S3 key :param encoding: utf-8 by default :param convert_to_json: auto-convert to a dict """ log.info('MOCK - mock_s3_read_contents_from_key') data = build_cache_ready_pricing_dataset() if not convert_as_json: data = json.dumps(data) return data