def test_init_record(self): # prepare args = {'vehicle_ref': '8761901', 'trip_id': '24104916_010117', 'recorded_at_time': datetime.datetime(2017, 2, 2, 16, 35, 48, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), 'route_offset': 0.362768825871595} # exec record = RealTimeArrivals.Record(**args) self.assertEqual(record.vehicle_ref, args['vehicle_ref']) self.assertEqual(record.trip_id, args['trip_id']) self.assertEqual(record.recorded_at_time, args['recorded_at_time']) self.assertEqual(record.route_offset, args['route_offset'])
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.4), RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 13), route_offset=0.8)]
RealTimeArrivals.Record(recorded_at_time=datetime.datetime(2017, 1, 1, 13), route_offset=1.8)] def read_stops(self, trip_id=None): return [RealTimeArrivals.Stop(stop_sequence=4, shape_dist_traveled=2500)] 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)