1
- import os
2
-
3
- import numpy as np
4
- import pandas as pd
5
1
import pytest
6
2
7
3
import 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
11
5
12
6
pytestmark = [
13
- pytest .mark .requires_api_key ,
14
7
pytest .mark .alpha_vantage ,
15
- pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" ),
16
8
]
17
9
18
10
@@ -21,36 +13,23 @@ class TestAVQuotes(object):
21
13
def setup_class (cls ):
22
14
pytest .importorskip ("lxml" )
23
15
24
- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
25
16
def test_invalid_symbol (self ):
26
- with pytest .raises (ValueError ):
17
+ with pytest .raises (ImmediateDeprecationError ):
27
18
web .get_quote_av ("BADSYMBOL" )
28
19
29
- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
30
20
def test_bad_multiple_symbol (self ):
31
- with pytest .raises (ValueError ):
21
+ with pytest .raises (ImmediateDeprecationError ):
32
22
web .get_quote_av (["AAPL" , "BADSYMBOL" ])
33
23
34
- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
35
24
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 )
41
27
42
- @pytest .mark .skipif (TEST_API_KEY is None , reason = "ALPHAVANTAGE_API_KEY not set" )
43
28
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 )
46
31
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" )
51
32
@pytest .mark .xfail (reason = "May return NaN outside of market hours" )
52
33
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