def test_init_stop(self): # prepare args = {'route_id': 10802, 'route_long_name': 'כניסה ראשית/הדסה עין כרם-ירושלים<->האוניברסיטה העברית הר הצופים-ירושלים-1א', 'trip_id': '24104916_010117', 'stop_sequence': 1, 'stop_id': 9863, 'route_short_name': '19', 'shape_dist_traveled': 0, 'arrival_time': '18:15:00'} # exec stop = RealTimeArrivals.Stop(**args) # test self.assertEqual(stop.route_id, args['route_id']) self.assertEqual(stop.trip_id, args['trip_id']) self.assertEqual(stop.stop_sequence, args['stop_sequence']) self.assertEqual(stop.stop_id, args['stop_id']) self.assertEqual(stop.route_id, args['route_id']) self.assertEqual(stop.shape_dist_traveled, args['shape_dist_traveled'])
def read_stops(self, trip_id=None): return [RealTimeArrivals.Stop(stop_sequence=4, shape_dist_traveled=1000)]
class StubRecordsRegular(Cruds.Crud): def read_records_from_siri(self, trip_id=None, trip_date=None): return [RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 12, 30), route_offset=0.5), RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 13), route_offset=1.5)] def read_stops(self, trip_id=None): return [RealTimeArrivals.Stop(stop_sequence=4, shape_dist_traveled=1000)] records = [RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 12), route_offset=0), RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 12, 30), route_offset=0.4), RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 13), route_offset=0.8)] stops = [RealTimeArrivals.Stop(stop_sequence=1, shape_dist_traveled=0), RealTimeArrivals.Stop(stop_sequence=2, shape_dist_traveled=500), RealTimeArrivals.Stop(stop_sequence=3, shape_dist_traveled=1500), RealTimeArrivals.Stop(stop_sequence=4, shape_dist_traveled=2500)] class TestGetBeforeAndAfter(unittest.TestCase): def test_stop_between_records(self): trip = RealTimeArrivals.Trip() trip.records = records[1:] trip._add_route_offset_in_meters(stops[-1].shape_dist_traveled) bef, aft = trip._get_before_and_after_records(stop=stops[2]) self.assertEqual(bef, records[1]) self.assertEqual(aft, records[2])