1- import os
2-
3- import numpy as np
4- import pandas as pd
51import pytest
62
73import pandas_datareader .data as web
8-
9- TEST_API_KEY = os .getenv ("ALPHAVANTAGE_API_KEY" )
10- TEST_API_KEY = None if not TEST_API_KEY else TEST_API_KEY
4+ from pandas_datareader .exceptions import ImmediateDeprecationError
115
126pytestmark = [
13- pytest .mark .requires_api_key ,
147 pytest .mark .alpha_vantage ,
15- pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" ),
168]
179
1810
@@ -21,36 +13,23 @@ class TestAVQuotes(object):
2113 def setup_class (cls ):
2214 pytest .importorskip ("lxml" )
2315
24- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
2516 def test_invalid_symbol (self ):
26- with pytest .raises (ValueError ):
17+ with pytest .raises (ImmediateDeprecationError ):
2718 web .get_quote_av ("BADSYMBOL" )
2819
29- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
3020 def test_bad_multiple_symbol (self ):
31- with pytest .raises (ValueError ):
21+ with pytest .raises (ImmediateDeprecationError ):
3222 web .get_quote_av (["AAPL" , "BADSYMBOL" ])
3323
34- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
3524 def test_single_symbol (self ):
36- df = web .get_quote_av ("AAPL" , retry_count = 6 , pause = 20.5 )
37- assert len (df ) == 1
38-
39- expected = pd .Index (["price" , "volume" , "timestamp" ])
40- assert df .columns .equals (expected )
25+ with pytest .raises (ImmediateDeprecationError ):
26+ web .get_quote_av ("AAPL" , retry_count = 6 , pause = 20.5 )
4127
42- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
4328 def test_multi_symbol (self ):
44- df = web . get_quote_av ([ "AAPL" , "TSLA" ], retry_count = 6 , pause = 20.5 )
45- assert len ( df ) == 2
29+ with pytest . raises ( ImmediateDeprecationError ):
30+ web . get_quote_av ([ "AAPL" , "TSLA" ], retry_count = 6 , pause = 20.5 )
4631
47- expected = pd .Index (["price" , "volume" , "timestamp" ])
48- assert df .columns .equals (expected )
49-
50- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
5132 @pytest .mark .xfail (reason = "May return NaN outside of market hours" )
5233 def test_return_types (self ):
53- df = web .get_quote_av ("AAPL" , retry_count = 6 , pause = 20.5 )
54-
55- assert isinstance (df ["AAPL" ]["price" ], np .int64 )
56- assert isinstance (df ["AAPL" ]["volume" ], np .float64 )
34+ with pytest .raises (ImmediateDeprecationError ):
35+ web .get_quote_av ("AAPL" , retry_count = 6 , pause = 20.5 )
0 commit comments