예제 #1
0
def test_populate_pb_with_full_dataset():
    """
    VJ cancelation
    """
    navitia_vj = {'trip': {'id': 'vehicle_journey:1'}}

    with app.app_context():
        trip_update = TripUpdate()
        vj = VehicleJourney(navitia_vj, datetime.date(2015, 9, 8))
        trip_update.vj = vj
        trip_update.status = 'delete'
        trip_update.message = 'Message Test'
        real_time_update = RealTimeUpdate(raw_data=None, connector='ire')
        trip_update.contributor = 'kisio-digital'
        real_time_update.trip_updates.append(trip_update)

        db.session.add(real_time_update)
        db.session.commit()

        feed_entity = convert_to_gtfsrt(real_time_update.trip_updates, gtfs_realtime_pb2.FeedHeader.FULL_DATASET)

        assert feed_entity.header.incrementality == gtfs_realtime_pb2.FeedHeader.FULL_DATASET
        assert feed_entity.header.gtfs_realtime_version == '1'
        pb_trip_update = feed_entity.entity[0].trip_update
        assert pb_trip_update.trip.trip_id == 'vehicle_journey:1'
        assert pb_trip_update.trip.start_date == '20150908'
        assert pb_trip_update.HasExtension(kirin_pb2.trip_message) == True
        assert pb_trip_update.Extensions[kirin_pb2.trip_message] == 'Message Test'
        assert pb_trip_update.trip.schedule_relationship == gtfs_realtime_pb2.TripDescriptor.CANCELED

        assert pb_trip_update.trip.HasExtension(kirin_pb2.contributor) == True
        assert pb_trip_update.trip.Extensions[kirin_pb2.contributor] == 'kisio-digital'

        assert len(feed_entity.entity[0].trip_update.stop_time_update) == 0
예제 #2
0
def test_populate_pb_with_full_dataset():
    """
    VJ cancelation
    """
    navitia_vj = {
        'trip': {
            'id': 'vehicle_journey:1'
        },
        'stop_times': [{
            'arrival_time': datetime.time(8, 10),
            'stop_point': {
                'stop_area': {
                    'timezone': 'UTC'
                }
            }
        }]
    }

    with app.app_context():
        trip_update = TripUpdate()
        vj = VehicleJourney(navitia_vj, datetime.date(2015, 9, 8))
        trip_update.vj = vj
        trip_update.status = 'delete'
        trip_update.message = 'Message Test'
        real_time_update = RealTimeUpdate(raw_data=None,
                                          connector='ire',
                                          contributor='realtime.ire')
        trip_update.contributor = 'kisio-digital'
        trip_update.company_id = 'keolis'
        trip_update.effect = 'DETOUR'
        real_time_update.trip_updates.append(trip_update)

        db.session.add(real_time_update)
        db.session.commit()

        feed_entity = convert_to_gtfsrt(
            real_time_update.trip_updates,
            gtfs_realtime_pb2.FeedHeader.FULL_DATASET)

        assert feed_entity.header.incrementality == gtfs_realtime_pb2.FeedHeader.FULL_DATASET
        assert feed_entity.header.gtfs_realtime_version == '1'
        pb_trip_update = feed_entity.entity[0].trip_update
        assert pb_trip_update.trip.trip_id == 'vehicle_journey:1'
        assert pb_trip_update.trip.start_date == '20150908'
        assert pb_trip_update.HasExtension(kirin_pb2.trip_message) == True
        assert pb_trip_update.Extensions[
            kirin_pb2.trip_message] == 'Message Test'
        assert pb_trip_update.trip.schedule_relationship == gtfs_realtime_pb2.TripDescriptor.CANCELED

        assert pb_trip_update.trip.HasExtension(kirin_pb2.contributor) == True
        assert pb_trip_update.trip.Extensions[
            kirin_pb2.contributor] == 'kisio-digital'
        assert pb_trip_update.trip.Extensions[kirin_pb2.company_id] == 'keolis'
        assert pb_trip_update.Extensions[
            kirin_pb2.effect] == gtfs_realtime_pb2.Alert.DETOUR

        assert len(feed_entity.entity[0].trip_update.stop_time_update) == 0
예제 #3
0
def test_populate_pb_with_cancelation():
    """
    VJ cancelation
    """
    navitia_vj = {
        "trip": {
            "id": "vehicle_journey:1"
        },
        "stop_times": [{
            "utc_arrival_time": datetime.time(8, 10),
            "stop_point": {
                "stop_area": {
                    "timezone": "UTC"
                }
            }
        }],
    }

    with app.app_context():
        vj = VehicleJourney(navitia_vj,
                            datetime.datetime(2015, 9, 8, 7, 10, 0),
                            datetime.datetime(2015, 9, 8, 11, 5, 0))
        trip_update = TripUpdate(vj=vj, contributor_id=COTS_CONTRIBUTOR_ID)
        trip_update.vj = vj
        trip_update.status = "delete"
        trip_update.message = "Message Test"
        real_time_update = make_rt_update(
            raw_data=None,
            connector_type=ConnectorType.cots.value,
            contributor_id=COTS_CONTRIBUTOR_ID)
        trip_update.company_id = "sncf"
        trip_update.effect = "REDUCED_SERVICE"
        real_time_update.trip_updates.append(trip_update)

        db.session.add(real_time_update)
        db.session.commit()

        feed_entity = convert_to_gtfsrt(real_time_update.trip_updates)

        assert feed_entity.header.incrementality == gtfs_realtime_pb2.FeedHeader.DIFFERENTIAL
        assert feed_entity.header.gtfs_realtime_version == "1"
        pb_trip_update = feed_entity.entity[0].trip_update
        assert pb_trip_update.trip.trip_id == "vehicle_journey:1"
        assert pb_trip_update.trip.start_date == "20150908"
        assert pb_trip_update.HasExtension(kirin_pb2.trip_message) is True
        assert pb_trip_update.Extensions[
            kirin_pb2.trip_message] == "Message Test"
        assert pb_trip_update.trip.schedule_relationship == gtfs_realtime_pb2.TripDescriptor.CANCELED

        assert pb_trip_update.trip.HasExtension(kirin_pb2.contributor) is True
        assert pb_trip_update.trip.Extensions[
            kirin_pb2.contributor] == COTS_CONTRIBUTOR_ID
        assert pb_trip_update.trip.Extensions[kirin_pb2.company_id] == "sncf"
        assert pb_trip_update.Extensions[
            kirin_pb2.effect] == gtfs_realtime_pb2.Alert.REDUCED_SERVICE

        assert len(feed_entity.entity[0].trip_update.stop_time_update) == 0
예제 #4
0
def test_populate_pb_with_cancelation():
    """
    VJ cancelation
    """
    navitia_vj = {
        'trip': {
            'id': 'vehicle_journey:1'
        },
        'stop_times': [{
            'utc_arrival_time': datetime.time(8, 10),
            'stop_point': {
                'stop_area': {
                    'timezone': 'UTC'
                }
            }
        }]
    }

    with app.app_context():
        trip_update = TripUpdate()
        vj = VehicleJourney(
            navitia_vj, utc.localize(datetime.datetime(2015, 9, 8, 7, 10, 0)),
            utc.localize(datetime.datetime(2015, 9, 8, 11, 5, 0)))
        trip_update.vj = vj
        trip_update.status = 'delete'
        trip_update.message = 'Message Test'
        real_time_update = RealTimeUpdate(raw_data=None,
                                          connector='cots',
                                          contributor='realtime.cots')
        trip_update.contributor = 'kisio-digital'
        trip_update.company_id = 'sncf'
        trip_update.effect = 'REDUCED_SERVICE'
        real_time_update.trip_updates.append(trip_update)

        db.session.add(real_time_update)
        db.session.commit()

        feed_entity = convert_to_gtfsrt(real_time_update.trip_updates)

        assert feed_entity.header.incrementality == gtfs_realtime_pb2.FeedHeader.DIFFERENTIAL
        assert feed_entity.header.gtfs_realtime_version == '1'
        pb_trip_update = feed_entity.entity[0].trip_update
        assert pb_trip_update.trip.trip_id == 'vehicle_journey:1'
        assert pb_trip_update.trip.start_date == '20150908'
        assert pb_trip_update.HasExtension(kirin_pb2.trip_message) == True
        assert pb_trip_update.Extensions[
            kirin_pb2.trip_message] == 'Message Test'
        assert pb_trip_update.trip.schedule_relationship == gtfs_realtime_pb2.TripDescriptor.CANCELED

        assert pb_trip_update.trip.HasExtension(kirin_pb2.contributor) == True
        assert pb_trip_update.trip.Extensions[
            kirin_pb2.contributor] == 'kisio-digital'
        assert pb_trip_update.trip.Extensions[kirin_pb2.company_id] == 'sncf'
        assert pb_trip_update.Extensions[
            kirin_pb2.effect] == gtfs_realtime_pb2.Alert.REDUCED_SERVICE

        assert len(feed_entity.entity[0].trip_update.stop_time_update) == 0
예제 #5
0
def test_populate_pb_with_cancelation():
    """
    VJ cancelation
    """
    navitia_vj = {'trip': {'id': 'vehicle_journey:1'}}

    with app.app_context():
        trip_update = TripUpdate()
        vj = VehicleJourney(navitia_vj, datetime.date(2015, 9, 8))
        trip_update.vj = vj
        trip_update.status = 'delete'
        trip_update.message = 'Message Test'
        real_time_update = RealTimeUpdate(raw_data=None, connector='ire')
        trip_update.contributor = 'kisio-digital'
        real_time_update.trip_updates.append(trip_update)

        db.session.add(real_time_update)
        db.session.commit()

        feed_entity = convert_to_gtfsrt(real_time_update.trip_updates)

        assert feed_entity.header.incrementality == gtfs_realtime_pb2.FeedHeader.DIFFERENTIAL
        assert feed_entity.header.gtfs_realtime_version == '1'
        pb_trip_update = feed_entity.entity[0].trip_update
        assert pb_trip_update.trip.trip_id == 'vehicle_journey:1'
        assert pb_trip_update.trip.start_date == '20150908'
        assert pb_trip_update.HasExtension(kirin_pb2.trip_message) == True
        assert pb_trip_update.Extensions[
            kirin_pb2.trip_message] == 'Message Test'
        assert pb_trip_update.trip.schedule_relationship == gtfs_realtime_pb2.TripDescriptor.CANCELED

        assert pb_trip_update.trip.HasExtension(kirin_pb2.contributor) == True
        assert pb_trip_update.trip.Extensions[
            kirin_pb2.contributor] == 'kisio-digital'

        assert len(feed_entity.entity[0].trip_update.stop_time_update) == 0