def setUp( self ): super( Test_StopFinder_Next_Stop, self ).setUp() timestamp= datetime.datetime( 2012, 2, 28, 6, 33, 0 ) lat, lon = 36.85192-self.feet250,-76.28732 time= (timestamp.hour*60+timestamp.minute)*60+timestamp.second self.arr= Arrival( timestamp=timestamp, id='3247', lat=lat, lon=lon, ll_valid='V', adher=-1, adher_valid='V', time=time, rte='28', dir='1', stop='30' ) self.loc= Location( timestamp=timestamp, id='3247', lat=lat, lon=lon, ll_valid='V', adher=-1, adher_valid='V', ) self.stop_finder= StopFinder_Next_Stop( self.connection )
class Test_StopFinder_Next_Stop( Sample_Transit_Data ): def setUp( self ): super( Test_StopFinder_Next_Stop, self ).setUp() timestamp= datetime.datetime( 2012, 2, 28, 6, 33, 0 ) lat, lon = 36.85192-self.feet250,-76.28732 time= (timestamp.hour*60+timestamp.minute)*60+timestamp.second self.arr= Arrival( timestamp=timestamp, id='3247', lat=lat, lon=lon, ll_valid='V', adher=-1, adher_valid='V', time=time, rte='28', dir='1', stop='30' ) self.loc= Location( timestamp=timestamp, id='3247', lat=lat, lon=lon, ll_valid='V', adher=-1, adher_valid='V', ) self.stop_finder= StopFinder_Next_Stop( self.connection ) def test_should_reject( self ): self.assertRaises( InvalidReport, self.stop_finder.process_report, ( self.loc ) ) def test_should_accept( self ): best_fit= self.stop_finder.process_report( self.arr ) self.assertTrue( 249 <= best_fit.distance <= 251 ) self.assertEqual( '53678', best_fit.stop_time['trip_id'] ) self.assertEqual( '0001', best_fit.stop_time['stop_id'] ) #print( best_fit ) self.assertEqual( '0406', best_fit.next['stop_id'] )