예제 #1
0
    def test_uses_get_quote_endpoint_when_market_is_closed(
            self, mock_alpha_vantage_get_quote_amazon):
        with freeze_time("2021-01-07T09:30:00Z"):
            price = bot.get_price("AMZN")

        assert price == 3138.38
        mock_alpha_vantage_get_quote_amazon.assert_called_once_with("AMZN")
예제 #2
0
    def test_uses_fmp_api_as_fallback_when_alpha_vantage_api_limit_exceeded(
            self, mock_fmp_api_get_price_response):
        with freeze_time("2021-01-07T15:31:00Z"):
            price = bot.get_price("AAPL")

        assert price == 126.66
        mock_fmp_api_get_price_response.assert_called_once()
예제 #3
0
    def test_returns_price_for_cryptocurrency(
            self, mock_alpha_vantage_get_currency_exchange_rate):
        price = bot.get_price("BTC")

        assert price == 23933.49
        mock_alpha_vantage_get_currency_exchange_rate.assert_called_once_with(
            "BTC", "USD")
예제 #4
0
    def test_returns_price_for_stock(self, mock_alpha_vantage_get_intraday):
        with freeze_time("2021-01-07T15:31:00Z"):
            price = bot.get_price("AMZN")

        assert price == 3112.70
        mock_alpha_vantage_get_intraday.assert_called_once_with("AMZN")
예제 #5
0
    def test_returns_price_for_stock(self,
                                     mock_alpha_vantage_get_intraday_amazon):
        price = bot.get_price("AMZN")

        assert price == 3112.70
        mock_alpha_vantage_get_intraday_amazon.assert_called_once_with("AMZN")