def test_get_dilutedeps_with_api_exception(self): with patch.object(intrinio_data.company_api, 'get_company_historical_data', \ side_effect=ApiException("Server Error")), \ patch('support.financial_cache.cache', new=nop.Nop()): with self.assertRaises(DataError): intrinio_data.get_diluted_eps('NON-EXISTENT-TICKER', 2018)
def test_historical_cashflow_stmt_with_api_exception(self): with patch.object(intrinio_data.FUNDAMENTALS_API, 'get_fundamental_standardized_financials', side_effect=ApiException("Not Found")), \ patch('support.financial_cache.cache', new=nop.Nop()): with self.assertRaises(DataError): intrinio_data.get_historical_cashflow_stmt( 'NON-EXISTENT-TICKER', 2018, 2018, None)
def test_read_company_data_point_with_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_data_point_number', side_effect=ApiException("Server Error")), \ patch('support.financial_cache.cache', new=nop.Nop()): with self.assertRaises(DataError): intrinio_data._read_company_data_point('NON-EXISTENT-TICKER', 'tag')
def test_latest_stock_prices_with_exception(self): with patch.object(intrinio_data.SECURITY_API, 'get_security_stock_prices', side_effect=ApiException("Not Found")), \ patch('support.financial_cache.cache', new=nop.Nop()): with self.assertRaises(DataError): intrinio_data.get_latest_close_price('XXX', datetime.date(2018, 1, 1), 5)
def test_latest_stock_prices_with_exception(self): with patch.object(intrinio_data.SECURITY_API, 'get_security_stock_prices', side_effect=ApiException("Not Found")), \ patch.object(FinancialCache, 'read', return_value=None), \ patch.object(FinancialCache, 'write', return_value=None): with self.assertRaises(DataError): intrinio_data.get_latest_close_price( 'XXX', datetime.date(2018, 1, 1), 5)
def test_historical_balacesheet_stmt_with_api_exception(self): with patch.object(intrinio_data.FUNDAMENTALS_API, 'get_fundamental_standardized_financials', side_effect=ApiException("Not Found")), \ patch.object(FinancialCache, 'read', return_value=None), \ patch.object(FinancialCache, 'write', return_value=None): with self.assertRaises(DataError): intrinio_data.get_historical_balance_sheet( 'NON-EXISTENT-TICKER', 2018, 2018, None)
def test_get_sma_indicator_with_api_exception(self): with patch.object(intrinio_data.SECURITY_API, 'get_security_price_technicals_sma', side_effect=ApiException("Not Found")), \ patch.object(FinancialCache, 'read', return_value=None), \ patch.object(FinancialCache, 'write', return_value=None): with self.assertRaises(DataError): intrinio_data.get_sma_indicator( 'AAPL', datetime.datetime(2020, 1, 1), datetime.datetime(2020, 5, 29), 50)
def test_read_company_data_point_with_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_data_point_number', side_effect=ApiException("Server Error")), \ patch.object(FinancialCache, 'read', return_value=None), \ patch.object(FinancialCache, 'write', return_value=None): with self.assertRaises(DataError): intrinio_data._read_company_data_point( 'NON-EXISTENT-TICKER', 'tag')
def test_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_historical_data', side_effect=ApiException("Not Found")): strategy = PriceDispersionStrategy(['1', '2'], 2020, 2, 1) with self.assertRaises(DataError): strategy.__load_financial_data__()
def test_read_financial_metric_with_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_historical_data', side_effect=ApiException("Server Error")), \ patch('support.financial_cache.cache', new=nop.Nop()): (start_date) = intrinio_util.get_year_date_range(2018, 0)[0] with self.assertRaises(DataError): intrinio_data._get_company_historical_data( 'NON-EXISTENT-TICKER', start_date, start_date, 'tag')
def test_retry_server_errors_api_error_501(self): with patch.object(time, 'sleep', return_value=None): mock = Mock(side_effect=DataError( "Mock error", ApiException(501, "Mock Error"))) test_function = intrinio_data.retry_server_errors(mock) with self.assertRaises(DataError): test_function() self.assertEqual(mock.call_count, self.RETRY_ERROR_COUNT)
def test_read_financial_metric_with_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_historical_data', side_effect=ApiException("Server Error")), \ patch.object(FinancialCache, 'read', return_value=None), \ patch.object(FinancialCache, 'write', return_value=None): (start_date) = intrinio_util.get_year_date_range(2018, 0)[0] with self.assertRaises(DataError): intrinio_data._get_company_historical_data( 'NON-EXISTENT-TICKER', start_date, start_date, 'tag')
def test_api_exception(self): with patch.object(intrinio_data.COMPANY_API, 'get_company_historical_data', side_effect=ApiException("Not Found")): strategy = PriceDispersionStrategy( TickerList.from_dict({ "list_name": "DOW30", "list_type": "US_EQUITIES", "comparison_symbol": "DIA", "ticker_symbols": ['AAPL', 'V'] }), '2000-05', date(2000, 6, 10), 3) with self.assertRaises(DataError): strategy._load_financial_data()
def test_daily_stock_prices_with_api_exception(self): with patch.object(intrinio_data.security_api, 'get_security_stock_prices', side_effect=ApiException("Not Found")), \ patch('support.financial_cache.cache', new=nop.Nop()): with self.assertRaises(DataError): intrinio_data.get_daily_stock_close_prices('NON-EXISTENT-TICKER', datetime.date(2018, 1, 1), datetime.date(2019, 1, 1))
def test_get_graham_number_with_exception(self): with patch.object(intrinio_data.company_api, 'get_company_historical_data', side_effect=ApiException("Not Found")): with self.assertRaises(DataError): calculator.calc_graham_number('NON-EXISTENT-TICKER', 2018)