コード例 #1
0
ファイル: test_stockservice.py プロジェクト: fagan2888/stocks
    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
ファイル: test_stockservice.py プロジェクト: fagan2888/stocks
    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])