Beispiel #1
0
    def test_case_3(self):
        """
        The train is currently INCOMING_AT a station somewhere along the route. This case is treated the same was as
        the case above.
        """
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': 1463026080,
                    'departure': 1463026080,
                    'stop_id': '103S'
                }, {
                    'arrival': 1463026170,
                    'departure': 1463026170,
                    'stop_id': '104S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'INCOMING_AT',
                'current_stop_sequence': 34,
                'stop_id': '103S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(log['action']) == [
            'EXPECTED_TO_ARRIVE_AT', 'EXPECTED_TO_DEPART_AT',
            'EXPECTED_TO_ARRIVE_AT', 'EXPECTED_TO_DEPART_AT',
            'EXPECTED_TO_ARRIVE_AT'
        ]
Beispiel #2
0
    def test_case_7(self):
        """
        The train is currently STOPPED_AT the final stop on its route.
        """
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'STOPPED_AT',
                'current_stop_sequence': 34,
                'stop_id': '140S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(log['action']) == ['STOPPED_AT']
Beispiel #3
0
    def test_case_4(self):
        """
        The train is queued. The train is not expected to skip any of the stops along the route.

        Every station except for the first and last has an EXPECTED_TO_ARRIVE_AT and
        EXPECTED_TO_DEPART_AT entry. The last only has an EXPECTED_TO_ARRIVE_AT entry. The first only has an
        EXPECTED_TO_DEPART_AT entry.
        """
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': np.nan,
                    'departure': 1463026080,
                    'stop_id': '103S'
                }, {
                    'arrival': 1463026170,
                    'departure': 1463026170,
                    'stop_id': '104S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, None, timestamp)
        assert list(log['action']) == [
            'EXPECTED_TO_DEPART_AT', 'EXPECTED_TO_ARRIVE_AT',
            'EXPECTED_TO_DEPART_AT', 'EXPECTED_TO_ARRIVE_AT'
        ]
Beispiel #4
0
    def test_case_9(self):
        """
        The train is expected to skip the first stop along its route.
        """
        # First subcase.
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': np.nan,
                    'departure': 1463026080,
                    'stop_id': '103S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'INCOMING_AT',
                'current_stop_sequence': 34,
                'stop_id': '103S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(
            log['action']) == ['EXPECTED_TO_SKIP', 'EXPECTED_TO_ARRIVE_AT']

        # Second subcase.
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': 1463026080,
                    'departure': np.nan,
                    'stop_id': '103S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'INCOMING_AT',
                'current_stop_sequence': 34,
                'stop_id': '103S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(
            log['action']) == ['EXPECTED_TO_SKIP', 'EXPECTED_TO_ARRIVE_AT']
Beispiel #5
0
    def test_case_8(self):
        """
        The train is somewhere along its trip, and follows all of the same rules as the similar earlier test cases
        thereof. However, it is also expected to skip one or more stops along its route.

        There are actually two such cases. In the first case, we have an intermediate station with only a departure.
        In the second, an intermediate station with only an arrival.

        One hopes that there isn't some special meaning attached to the difference between the two.
        """
        # First subcase.
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': 1463026080,
                    'departure': 1463026080,
                    'stop_id': '103S'
                }, {
                    'arrival': 1463026170,
                    'departure': np.nan,
                    'stop_id': '104S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'INCOMING_AT',
                'current_stop_sequence': 34,
                'stop_id': '103S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(log['action']) == [
            'EXPECTED_TO_ARRIVE_AT', 'EXPECTED_TO_DEPART_AT',
            'EXPECTED_TO_SKIP', 'EXPECTED_TO_ARRIVE_AT'
        ]

        # Second subcase.
        trip_message = {
            'id': '000001',
            'type': 'trip_update',
            'trip_update': {
                'trip': {
                    'route_id': '1',
                    'start_date': '20160512',
                    'trip_id': '000650_1..S02R'
                },
                'stop_time_update': [{
                    'arrival': 1463026080,
                    'departure': 1463026080,
                    'stop_id': '103S'
                }, {
                    'arrival': np.nan,
                    'departure': 1463026170,
                    'stop_id': '104S'
                }, {
                    'arrival': 1463029500,
                    'departure': np.nan,
                    'stop_id': '140S'
                }]
            }
        }
        vehicle_message = {
            'id': '000006',
            'type': 'vehicle_update',
            'vehicle': {
                'current_status': 'INCOMING_AT',
                'current_stop_sequence': 34,
                'stop_id': '103S',
                'timestamp': 1463025417,
                'trip': {
                    'route_id': '1',
                    'start_date': '20160511',
                    'trip_id': '137100_1..N02X017'
                }
            }
        }
        timestamp = 1463025417

        log = gt.actionify(trip_message, vehicle_message, timestamp)
        assert list(log['action']) == [
            'EXPECTED_TO_ARRIVE_AT', 'EXPECTED_TO_DEPART_AT',
            'EXPECTED_TO_SKIP', 'EXPECTED_TO_ARRIVE_AT'
        ]