コード例 #1
0
 def testExactTimesStringValueConversion(self):
     # Test that no exact_times converts to 0
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800"})
     frequency.validate_before_add(self.problems)
     self.assertEquals(frequency.get_exact_times(), 0)
     # Test that empty exact_times converts to 0
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800",
                     "exact_times": ""})
     frequency.validate_before_add(self.problems)
     self.assertEquals(frequency.get_exact_times(), 0)
     # Test that exact_times "0" converts to 0
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800",
                     "exact_times": "0"})
     frequency.validate_before_add(self.problems)
     self.assertEquals(frequency.get_exact_times(), 0)
     # Test that exact_times "1" converts to 1
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800",
                     "exact_times": "1"})
     frequency.validate_before_add(self.problems)
     self.assertEquals(frequency.get_exact_times(), 1)
     self.accumulator.assert_no_more_exceptions()
コード例 #2
0
 def testExactTimesInvalidValues(self):
     # Test that exact_times 15 raises error
     frequency = transitfeed.Frequency(
         field_dict={
             "trip_id": "AB1,10",
             "start_time": "10:00:00",
             "end_time": "23:01:00",
             "headway_secs": "1800",
             "exact_times": 15,
         }
     )
     frequency.ValidateBeforeAdd(self.problems)
     self.accumulator.PopInvalidValue("exact_times")
     self.accumulator.AssertNoMoreExceptions()
     # Test that exact_times "yes" raises error
     frequency = transitfeed.Frequency(
         field_dict={
             "trip_id": "AB1,10",
             "start_time": "10:00:00",
             "end_time": "23:01:00",
             "headway_secs": "1800",
             "exact_times": "yes",
         }
     )
     frequency.ValidateBeforeAdd(self.problems)
     self.accumulator.PopInvalidValue("exact_times")
     self.accumulator.AssertNoMoreExceptions()
コード例 #3
0
    def testNonOverlappingPeriods(self):
        headway_period1 = transitfeed.Frequency({'trip_id': '054C-00',
                                                 'start_time': '06:00:00',
                                                 'end_time': '12:00:00',
                                                 'headway_secs': 600,
                                                 })
        headway_period2 = transitfeed.Frequency({'trip_id': '054C-00',
                                                 'start_time': '01:00:00',
                                                 'end_time': '02:00:00',
                                                 'headway_secs': 1200,
                                                 })
        headway_period3 = transitfeed.Frequency({'trip_id': '054C-00',
                                                 'start_time': '04:00:00',
                                                 'end_time': '05:00:00',
                                                 'headway_secs': 1000,
                                                 })
        headway_period4 = transitfeed.Frequency({'trip_id': '054C-00',
                                                 'start_time': '12:00:00',
                                                 'end_time': '19:00:00',
                                                 'headway_secs': 700,
                                                 })

        # expect no problems for non-overlapping periods
        headway_period1.add_to_schedule(self.schedule, self.problems)
        headway_period2.add_to_schedule(self.schedule, self.problems)
        headway_period3.add_to_schedule(self.schedule, self.problems)
        headway_period4.add_to_schedule(self.schedule, self.problems)
        self.trip.validate(self.problems)
        self.accumulator.assert_no_more_exceptions()
        self.trip.clear_frequencies()
コード例 #4
0
 def testOverlappingPeriods(self):
     # overlapping headway periods
     headway_period1 = transitfeed.Frequency({'trip_id': '054C-00',
                                              'start_time': '00:00:00',
                                              'end_time': '12:00:00',
                                              'headway_secs': 600,
                                              })
     headway_period2 = transitfeed.Frequency({'trip_id': '054C-00',
                                              'start_time': '06:00:00',
                                              'end_time': '18:00:00',
                                              'headway_secs': 1200,
                                              })
     headway_period1.add_to_schedule(self.schedule, self.problems)
     headway_period2.add_to_schedule(self.schedule, self.problems)
     self.ValidateAndExpectOtherProblem(self.trip)
     self.trip.clear_frequencies()
     self.accumulator.assert_no_more_exceptions()
コード例 #5
0
 def testExactTimesInvalidValues(self):
     # Test that exact_times 15 raises error
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800",
                     "exact_times": 15})
     frequency.validate_before_add(self.problems)
     self.accumulator.pop_invalid_value("exact_times")
     self.accumulator.assert_no_more_exceptions()
     # Test that exact_times "yes" raises error
     frequency = transitfeed.Frequency(
         field_dict={"trip_id": "AB1,10", "start_time": "10:00:00",
                     "end_time": "23:01:00", "headway_secs": "1800",
                     "exact_times": "yes"})
     frequency.validate_before_add(self.problems)
     self.accumulator.pop_invalid_value("exact_times")
     self.accumulator.assert_no_more_exceptions()
コード例 #6
0
ファイル: feed.py プロジェクト: usuariobkp/gtfseditor
 def loadAllFrequencies(self):
     logger.info("Loading Frequencies")
     for freq in self.db.query(Frequency).all():
       f = transitfeed.Frequency({'trip_id':freq.trip_id, 
           'start_time':freq.start_time, 
           'end_time':freq.end_time, 
           'headway_secs':freq.headway_secs})
       f.AddToSchedule(self.schedule)
コード例 #7
0
 def testPeriodWithInvalidTripId(self):
     headway_period1 = transitfeed.Frequency({'trip_id': 'foo',
                                              'start_time': '00:00:00',
                                              'end_time': '12:00:00',
                                              'headway_secs': 600,
                                              })
     headway_period1.add_to_schedule(self.schedule, self.problems)
     e = self.accumulator.PopException('InvalidValue')
     self.assertEqual('trip_id', e.column_name)
     self.trip.clear_frequencies()
コード例 #8
0
    def testNonOverlappingPeriods(self):
        headway_period1 = transitfeed.Frequency(
            {
                "trip_id": "054C-00",
                "start_time": "06:00:00",
                "end_time": "12:00:00",
                "headway_secs": 600,
            }
        )
        headway_period2 = transitfeed.Frequency(
            {
                "trip_id": "054C-00",
                "start_time": "01:00:00",
                "end_time": "02:00:00",
                "headway_secs": 1200,
            }
        )
        headway_period3 = transitfeed.Frequency(
            {
                "trip_id": "054C-00",
                "start_time": "04:00:00",
                "end_time": "05:00:00",
                "headway_secs": 1000,
            }
        )
        headway_period4 = transitfeed.Frequency(
            {
                "trip_id": "054C-00",
                "start_time": "12:00:00",
                "end_time": "19:00:00",
                "headway_secs": 700,
            }
        )

        # expect no problems for non-overlapping periods
        headway_period1.AddToSchedule(self.schedule, self.problems)
        headway_period2.AddToSchedule(self.schedule, self.problems)
        headway_period3.AddToSchedule(self.schedule, self.problems)
        headway_period4.AddToSchedule(self.schedule, self.problems)
        self.trip.Validate(self.problems)
        self.accumulator.AssertNoMoreExceptions()
        self.trip.ClearFrequencies()
コード例 #9
0
ファイル: feed.py プロジェクト: usuariobkp/gtfseditor
  def loadTripRouteFrequencies(self, trip):
      logger.info("Loading trip route Frequencies")

      services = self.db.query(RouteFrequency).filter_by(route_id=trip.route_id, 
        service_id=trip.service_id).all()
      for route_service in services:
        f = transitfeed.Frequency({'trip_id': trip.trip_id,
            'start_time': route_service.start_time,
            'end_time': route_service.end_time,
            'headway_secs': route_service.headway_secs})
        f.AddToSchedule(self.schedule)
コード例 #10
0
 def testPeriodWithInvalidTripId(self):
     headway_period1 = transitfeed.Frequency(
         {
             "trip_id": "foo",
             "start_time": "00:00:00",
             "end_time": "12:00:00",
             "headway_secs": 600,
         }
     )
     headway_period1.AddToSchedule(self.schedule, self.problems)
     e = self.accumulator.PopException("InvalidValue")
     self.assertEqual("trip_id", e.column_name)
     self.trip.ClearFrequencies()
コード例 #11
0
 def testExactTimesAsIntValue(self):
     # Test that exact_times None converts to 0
     frequency = transitfeed.Frequency(
         field_dict={
             "trip_id": "AB1,10",
             "start_time": "10:00:00",
             "end_time": "23:01:00",
             "headway_secs": "1800",
             "exact_times": None,
         }
     )
     frequency.ValidateBeforeAdd(self.problems)
     self.assertEquals(frequency.ExactTimes(), 0)
     # Test that exact_times 0 remains 0
     frequency = transitfeed.Frequency(
         field_dict={
             "trip_id": "AB1,10",
             "start_time": "10:00:00",
             "end_time": "23:01:00",
             "headway_secs": "1800",
             "exact_times": 0,
         }
     )
     frequency.ValidateBeforeAdd(self.problems)
     self.assertEquals(frequency.ExactTimes(), 0)
     # Test that exact_times 1 remains 1
     frequency = transitfeed.Frequency(
         field_dict={
             "trip_id": "AB1,10",
             "start_time": "10:00:00",
             "end_time": "23:01:00",
             "headway_secs": "1800",
             "exact_times": 1,
         }
     )
     frequency.ValidateBeforeAdd(self.problems)
     self.assertEquals(frequency.ExactTimes(), 1)
     self.accumulator.AssertNoMoreExceptions()
コード例 #12
0
 def testOverlappingPeriods(self):
     # overlapping headway periods
     headway_period1 = transitfeed.Frequency(
         {
             "trip_id": "054C-00",
             "start_time": "00:00:00",
             "end_time": "12:00:00",
             "headway_secs": 600,
         }
     )
     headway_period2 = transitfeed.Frequency(
         {
             "trip_id": "054C-00",
             "start_time": "06:00:00",
             "end_time": "18:00:00",
             "headway_secs": 1200,
         }
     )
     headway_period1.AddToSchedule(self.schedule, self.problems)
     headway_period2.AddToSchedule(self.schedule, self.problems)
     self.ValidateAndExpectOtherProblem(self.trip)
     self.trip.ClearFrequencies()
     self.accumulator.AssertNoMoreExceptions()