@@ -96,6 +96,78 @@ def test_get_data(self):
96
96
t = np .array (pan )
97
97
assert np .issubdtype (t .dtype , np .floating )
98
98
99
+ @network
100
+ def test_options (self ):
101
+ try :
102
+ import lxml
103
+ except ImportError :
104
+ raise nose .SkipTest
105
+ try :
106
+ # aapl has monthlies
107
+ aapl = web .Options ('aapl' , 'yahoo' )
108
+ today = datetime .today ()
109
+ year = today .year
110
+ month = today .month + 1
111
+ if (month > 12 ):
112
+ year = year + 1
113
+ month = 1
114
+ expiry = datetime (year , month , 1 )
115
+ (calls , puts ) = aapl .get_options_data (expiry = expiry )
116
+ assert len (calls )> 1
117
+ assert len (puts )> 1
118
+ (calls , puts ) = aapl .get_near_stock_price (call = True , put = True , expiry = expiry )
119
+ assert len (calls )== 5
120
+ assert len (puts )== 5
121
+ calls = aapl .get_call_data (expiry = expiry )
122
+ assert len (calls )> 1
123
+ puts = aapl .get_put_data (expiry = expiry )
124
+ assert len (puts )> 1
125
+ except IOError :
126
+ try :
127
+ urllib2 .urlopen ('http://www.google.com' )
128
+ except IOError :
129
+ raise nose .SkipTest
130
+ else :
131
+ raise
132
+
133
+ @network
134
+ def test_options_warnings (self ):
135
+ try :
136
+ import lxml
137
+ except ImportError :
138
+ raise nose .SkipTest
139
+ try :
140
+ import warnings
141
+ with warnings .catch_warnings (record = True ) as w :
142
+ warnings .resetwarnings ()
143
+ # Cause all warnings to always be triggered.
144
+ warnings .simplefilter ("always" )
145
+ # aapl has monthlies
146
+ aapl = web .Options ('aapl' )
147
+ today = datetime .today ()
148
+ year = today .year
149
+ month = today .month + 1
150
+ if (month > 12 ):
151
+ year = year + 1
152
+ month = 1
153
+ (calls , puts ) = aapl .get_options_data (month = month , year = year )
154
+ (calls , puts ) = aapl .get_near_stock_price (call = True , put = True , month = month , year = year )
155
+ calls = aapl .get_call_data (month = month , year = year )
156
+ puts = aapl .get_put_data (month = month , year = year )
157
+ print (w )
158
+ assert len (w ) == 5
159
+ assert "deprecated" in str (w [0 ].message )
160
+ assert "deprecated" in str (w [1 ].message )
161
+ assert "deprecated" in str (w [2 ].message )
162
+ assert "deprecated" in str (w [3 ].message )
163
+ assert "deprecated" in str (w [4 ].message )
164
+ except IOError :
165
+ try :
166
+ urllib2 .urlopen ('http://www.google.com' )
167
+ except IOError :
168
+ raise nose .SkipTest
169
+ else :
170
+ raise
99
171
100
172
if __name__ == '__main__' :
101
173
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
0 commit comments