66import pandas .io .data as web
77from pandas .util .testing import (network , assert_series_equal )
88from numpy .testing .decorators import slow
9+ import numpy as np
910
1011import urllib2
1112
@@ -24,7 +25,23 @@ def test_google(self):
2425 self .assertEquals (
2526 web .DataReader ("F" , 'google' , start , end )['Close' ][- 1 ],
2627 13.68 )
28+ except urllib2 .URLError :
29+ try :
30+ urllib2 .urlopen ('http://www.google.com' )
31+ except urllib2 .URLError :
32+ raise nose .SkipTest
33+ else :
34+ raise
2735
36+ @network
37+ def test_google_non_existent (self ):
38+ # asserts that google is minimally working and that it throws
39+ # an excecption when DataReader can't get a 200 response from
40+ # google
41+ start = datetime (2010 , 1 , 1 )
42+ end = datetime (2013 , 01 , 27 )
43+
44+ try :
2845 self .assertRaises (
2946 Exception ,
3047 lambda : web .DataReader ("NON EXISTENT TICKER" , 'google' ,
@@ -44,18 +61,36 @@ def test_get_quote(self):
4461 lambda : web .get_quote_google (pd .Series (['GOOG' , 'AAPL' , 'GOOG' ])))
4562
4663 @network
47- def test_get_data (self ):
64+ def test_get_goog_volume (self ):
4865 try :
49- import numpy as np
5066 df = web .get_data_google ('GOOG' )
51- print (df .Volume .ix ['OCT-08-2010' ])
5267 assert df .Volume .ix ['OCT-08-2010' ] == 2863473
68+ except IOError :
69+ try :
70+ urllib2 .urlopen ('http://www.google.com' )
71+ except IOError :
72+ raise nose .SkipTest
73+ else :
74+ raise
5375
76+ @network
77+ def test_get_multi1 (self ):
78+ try :
5479 sl = ['AAPL' , 'AMZN' , 'GOOG' ]
5580 pan = web .get_data_google (sl , '2012' )
5681 ts = pan .Close .GOOG .index [pan .Close .AAPL > pan .Close .GOOG ]
5782 assert ts [0 ].dayofyear == 96
83+ except IOError :
84+ try :
85+ urllib2 .urlopen ('http://www.google.com' )
86+ except IOError :
87+ raise nose .SkipTest
88+ else :
89+ raise
5890
91+ @network
92+ def test_get_multi2 (self ):
93+ try :
5994 pan = web .get_data_google (['GE' , 'MSFT' , 'INTC' ], 'JAN-01-12' , 'JAN-31-12' )
6095 expected = [19.02 , 28.23 , 25.39 ]
6196 result = pan .Close .ix ['01-18-12' ][['GE' , 'MSFT' , 'INTC' ]].tolist ()
0 commit comments