def test_loop(self): for i in finList: self.stock = base.TickerBase(i) print("Test: Loop\n " + "Stock: " + i) data = {} alist = [] _financials = { "yearly": self.stock.get_financials(), "quarterly": self.stock.get_financials(freq='quarterly') } print(_financials) _balancesheet = { "yearly": self.stock.get_balance_sheet(), "quarterly": self.stock.get_balance_sheet(freq='quarterly') } print(_balancesheet) _cashflow = { "yearly": self.stock.get_cashflow(), "quarterly": self.stock.get_cashflow(freq='quarterly') } print(_cashflow) for key in ((_cashflow, 'cashflowStatement', 'cashflowStatements'), (_balancesheet, 'balanceSheet', 'balanceSheetStatements'), (_financials, 'incomeStatement', 'incomeStatementHistory')): item = key[1] + 'History' alist.append(item) for i in range(len(alist)): if i == 0: self.assertTrue(alist[i] == "cashflowStatementHistory") elif i == 1: self.assertTrue(alist[i] == "balanceSheetHistory") elif i == 2: self.assertTrue(alist[i] == "incomeStatementHistory")
def test_empty(self): for i in finList: self.stock = base.TickerBase(i) data = {} alist = [] _financials = { "yearly": self.stock.get_financials(), "quarterly": self.stock.get_financials(freq='quarterly') } self.assertTrue( _financials['yearly'].empty == False or _financials['quarterly'].empty == False, "Cannot have empty financial statements") _balancesheet = { "yearly": self.stock.get_balance_sheet(), "quarterly": self.stock.get_balance_sheet(freq='quarterly') } self.assertTrue( _balancesheet['yearly'].empty == False or _balancesheet['quarterly'].empty == False, "Cannot have empty financial statements") _cashflow = { "yearly": self.stock.get_cashflow(), "quarterly": self.stock.get_cashflow(freq='quarterly') } self.assertTrue( _cashflow['yearly'].empty == False or _cashflow['quarterly'].empty == False, "Cannot have empty financial statements")
def test_is_dict(self): for i in finList: self.stock = base.TickerBase(i) print("Test: Dictionary type\n " + "Stock: " + i) empty_dict = dict() data = self.stock.generic_patterns(dict()) self.assertTrue(isinstance(data, dict))
def test_switch_statement(self): for i in finList: self.stock = base.TickerBase(i) print("Test: test_switch_statement\n " + "Stock: " + i) data = {} msg = "" _financials = { "yearly": self.stock.get_financials(), "quarterly": self.stock.get_financials(freq='quarterly') } _balancesheet = { "yearly": self.stock.get_balance_sheet(), "quarterly": self.stock.get_balance_sheet(freq='quarterly') } _cashflow = { "yearly": self.stock.get_cashflow(), "quarterly": self.stock.get_cashflow(freq='quarterly') } for key in ((_cashflow, 'cashflowStatement', 'cashflowStatements'), (_balancesheet, 'balanceSheet', 'balanceSheetStatements'), (_financials, 'incomeStatement', 'incomeStatementHistory')): item = key[1] + 'History' if isinstance(data.get(item), dict): try: msg += base.cleanup('yearly') except Exception as e: pass item = key[1] + 'HistoryQuarterly' if isinstance(data.get(item), dict): try: msg += base.cleanup('quarterly') except Exception as e: pass if (not isinstance(data.get(item), dict)): msg += "Empty DataFrame" self.assertTrue(msg == "Empty DataFrame")
def test_SFL_info(self): SFL = base.TickerBase(ticker="SFL") info = SFL.get_info() # if info doesn't fail then it worked self.assertIsNotNone(info)
def test_info(self): stocks = [base.TickerBase(symbol) for symbol in symbols] for stock in stocks: info = stock.get_info() self.assertIsNotNone(info)
def test_ACGL_info(self): acgl = base.TickerBase(ticker="ACGL") info = acgl.get_info() # if info doesn't fail then it worked self.assertIsNotNone(info)
def test_bnko_info(self): bnko = base.TickerBase(ticker="BNKO") info = bnko.get_info() self.assertTrue(info['maxAge'])
def test_htoo_info(self): htoo = base.TickerBase(ticker="HTOO") info = htoo.get_info() self.assertTrue(info['maxAge'])
def test_msft_info(self): msft = base.TickerBase(ticker="MSFT") info = msft.get_info() self.assertTrue(info['maxAge'])
def test_is_dict(self): msft = base.TickerBase(ticker="MSFT") empty_dict = dict() data = msft.generic_patterns(empty_dict) self.assertTrue(isinstance(data, dict))