Пример #1
0
    def test_get_stock_online(self):
        stockservice.connect()

        keys = [
            'change_number', 'change_percentage', 'exchange_name',
            'last_trade_date_and_time', 'last_trade_price', 'ticker_name'
        ]

        # Test getting one stock
        stock = stockservice.get_stock_information("AAPL")
        self.assertTrue(isinstance(stock, dict))

        # Assert all of the keys are in the stock
        intersection = set(keys).intersection(stock)
        self.assertEqual(6, len(intersection))
Пример #2
0
    def test_get_stock_online(self):
        stockservice.connect()

        keys = [
            "change_number",
            "change_percentage",
            "exchange_name",
            "last_trade_date_and_time",
            "last_trade_price",
            "ticker_name",
        ]

        # Test getting one stock
        stock = stockservice.get_stock_information("AAPL")
        self.assertTrue(isinstance(stock, dict))

        # Assert all of the keys are in the stock
        intersection = set(keys).intersection(stock)
        self.assertEqual(6, len(intersection))
Пример #3
0
    def test_throw_exception(self):
        stockservice.connect()

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information(["AAPL"])

        self.assertEqual("Please enter a string of Stock Tickers", context.exception.args[0])

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information(1)

        self.assertEqual("Please enter a string of Stock Tickers", context.exception.args[0])

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information("INVALID_STOCK")

        self.assertEqual("Make sure you entered a valid stock", context.exception.args[0])
Пример #4
0
    def test_throw_exception(self):
        stockservice.connect()

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information(["AAPL"])

        self.assertEqual('Please enter a string of Stock Tickers',
                         context.exception.args[0])

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information(1)

        self.assertEqual('Please enter a string of Stock Tickers',
                         context.exception.args[0])

        with self.assertRaises(stockservice.StockServiceException) as context:
            stockservice.get_stock_information("INVALID_STOCK")

        self.assertEqual('Make sure you entered a valid stock',
                         context.exception.args[0])