def refresh_list_box(self): self.lstboxStockCash.delete(0, END) stock_cash_table = StockCashTable() stock_cash_list = stock_cash_table.get_all_stock_cash() for stock_cash in stock_cash_list: self.lstboxStockCash.insert(END, stock_cash.get_symbol()) return
def get_cash_pool_text(self): result = "" stock_cash_table = StockCashTable() stock_cash_list = stock_cash_table.get_all_stock_cash() for stock_cash in stock_cash_list: result = result + "{0}".format(stock_cash) + "\n" return result
def fill_symbol_combobox(self): stock_cash_table = StockCashTable() stock_cash_list = stock_cash_table.get_all_stock_cash() symbol_list = [] for stock_cash in stock_cash_list: symbol_list.append(stock_cash.get_symbol()) self.cbbSymbol["values"] = symbol_list return
def test_stock_cash_sanity(self): stock_db_connection = get_default_db_connection() reset_table(stock_db_connection) stock_cash_table = StockCashTable(stock_db_connection) stock_cash = StockCash("601398", 1000) stock_cash_table.add_stock_cash(stock_cash) # test the new created line stock_cash = stock_cash_table.get_stock_cash_by_symbol("601398") self.assertEqual(stock_cash.get_symbol(), "601398") self.assertEqual(stock_cash.get_amount(), 1000) # test update stock cash stock_cash.set_amount(23.456) stock_cash_table.update_stock_cash(stock_cash) stock_cash = stock_cash_table.get_stock_cash_by_symbol("601398") self.assertEqual(stock_cash.get_amount(), 23.456) # test an unavailable line stock_cash = stock_cash_table.get_stock_cash_by_symbol("XXXXXX") self.assertEqual(stock_cash, None) # insert a new line, and test get_all function stock_cash = StockCash("601857", 5000) stock_cash_table.add_stock_cash(stock_cash) stock_cash_list = stock_cash_table.get_all_stock_cash() self.assertEqual(len(stock_cash_list), 2) stock_cash = stock_cash_list[0] self.assertEqual(stock_cash.get_symbol(), "601398") self.assertEqual(stock_cash.get_amount(), 23.456) stock_cash = stock_cash_list[1] self.assertEqual(stock_cash.get_symbol(), "601857") self.assertEqual(stock_cash.get_amount(), 5000) # delete a line stock_cash = StockCash("601398", 0) stock_cash_table.delete_stock_cash(stock_cash) stock_cash = stock_cash_table.get_stock_cash_by_symbol("601398") self.assertEqual(stock_cash, None)