6
6
import pandas .io .data as web
7
7
from pandas .util .testing import (network , assert_series_equal )
8
8
from numpy .testing .decorators import slow
9
+ import numpy as np
9
10
10
11
import urllib2
11
12
@@ -24,7 +25,23 @@ def test_google(self):
24
25
self .assertEquals (
25
26
web .DataReader ("F" , 'google' , start , end )['Close' ][- 1 ],
26
27
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
27
35
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 :
28
45
self .assertRaises (
29
46
Exception ,
30
47
lambda : web .DataReader ("NON EXISTENT TICKER" , 'google' ,
@@ -44,18 +61,36 @@ def test_get_quote(self):
44
61
lambda : web .get_quote_google (pd .Series (['GOOG' , 'AAPL' , 'GOOG' ])))
45
62
46
63
@network
47
- def test_get_data (self ):
64
+ def test_get_goog_volume (self ):
48
65
try :
49
- import numpy as np
50
66
df = web .get_data_google ('GOOG' )
51
- print (df .Volume .ix ['OCT-08-2010' ])
52
67
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
53
75
76
+ @network
77
+ def test_get_multi1 (self ):
78
+ try :
54
79
sl = ['AAPL' , 'AMZN' , 'GOOG' ]
55
80
pan = web .get_data_google (sl , '2012' )
56
81
ts = pan .Close .GOOG .index [pan .Close .AAPL > pan .Close .GOOG ]
57
82
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
58
90
91
+ @network
92
+ def test_get_multi2 (self ):
93
+ try :
59
94
pan = web .get_data_google (['GE' , 'MSFT' , 'INTC' ], 'JAN-01-12' , 'JAN-31-12' )
60
95
expected = [19.02 , 28.23 , 25.39 ]
61
96
result = pan .Close .ix ['01-18-12' ][['GE' , 'MSFT' , 'INTC' ]].tolist ()
0 commit comments