#NEWLINE# def test_fetch( self ) : #NEWLINE# #INDENT# f = YahooDayFetcher ( ) #NEWLINE# s1 = YahooSecurity ( YahooNA ( ) , 'GOOG' ) #NEWLINE# s2 = YahooSecurity ( YahooNA ( ) , 'AAPL' ) #NEWLINE# def callback( security , body ) : #NEWLINE# #INDENT# iters = YahooDay . parse ( security , body ) #NEWLINE# i = 0 #NEWLINE# for ohlc in iters : #NEWLINE# #INDENT# self . assertTrue ( ( ohlc . security in ( s1 , s2 ) ) ) #NEWLINE# if ( ( i == 0 ) and ( ohlc . security == s1 ) ) : #NEWLINE# #INDENT# self . assertEqual ( str ( ohlc . date ) , '2011-04-28' ) #NEWLINE# self . assertEqual ( ohlc . open , 538.06 ) #NEWLINE# self . assertEqual ( ohlc . high , 539.25 ) #NEWLINE# self . assertEqual ( ohlc . low , 534.08 ) #NEWLINE# self . assertEqual ( ohlc . close , 537.97 ) #NEWLINE# self . assertEqual ( ohlc . volume , 2037400.0 ) #NEWLINE# #UNINDENT# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# start_date = datetime . datetime . strptime ( '2011-04-01' , '%Y-%m-%d' ) . date ( ) #NEWLINE# end_date = datetime . datetime . strptime ( '2011-04-28' , '%Y-%m-%d' ) . date ( ) #NEWLINE# f . fetch ( s1 , s2 , callback = callback , start_date = start_date , end_date = end_date )