예제 #1
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.testApi = Api()
        self.testStock = Stock("jnj")

    def tearDown(self):
        del self.testStock
        del self.testApi

    def test_incorrect_stock(self):
        with self.assertRaises(ValueError):
            badStock = Stock("jiok")
            self.testApi.get_stock_quote(badStock)

    def test_no_input_stock(self):
        with self.assertRaises(ValueError):
            badStock = Stock("")
            self.testApi.get_stock_quote(badStock)

    def test_api_call(self):
        test = self.testApi.get_stock_quote(self.testStock)
        self.assertIs(type(test.last_price), float)
        self.assertIs(type(test.last_price_update), datetime)
예제 #2
0
        def get_data():
            """
            Gets data from profit loss window
            :return:
            """
            database = Database()
            complete_list_of_stocks = []
            list_of_bare_stocks = database.get_all_stocks()
            ready_for_display_stocks = []

            for x in list_of_bare_stocks:
                item = database.get_stock(x.symbol)
                complete_list_of_stocks.append(item)

            api = Api()

            for z in complete_list_of_stocks:
                item = api.get_stock_quote(z)
                ready_for_display_stocks.append(item)
            return ready_for_display_stocks
예제 #3
0
    def generate_main_stock_window_list(self):
        """
        Gets list of current stock, gets current quote, and calls method to put on main window.
        Call this method to execute list of current stocks on main window
        :return: none
        """
        database = Database()
        complete_list_of_stocks = []
        list_of_bare_stocks = database.get_all_stocks()
        ready_for_display_stocks = []

        for x in list_of_bare_stocks:
             item = database.get_stock(x.symbol)
             complete_list_of_stocks.append(item)

        api = Api()

        for z in complete_list_of_stocks:
            item = api.get_stock_quote(z)
            ready_for_display_stocks.append(item)

        self.adjust_stock_list(ready_for_display_stocks)