<s> from __future__ import absolute_import <EOL> from tests import util <EOL> import transitfeed <EOL> class FrequencyValidationTestCase ( util . ValidationTestCase ) : <EOL> def setUp ( self ) : <EOL> util . ValidationTestCase . setUp ( self ) <EOL> self . schedule = self . SimpleSchedule ( ) <EOL> trip = transitfeed . Trip ( ) <EOL> trip . route_id = '<STR_LIT>' <EOL> trip . service_id = '<STR_LIT>' <EOL> trip . trip_id = '<STR_LIT>' <EOL> trip . trip_headsign = '<STR_LIT>' <EOL> trip . direction_id = '<STR_LIT:0>' <EOL> trip . block_id = None <EOL> trip . shape_id = None <EOL> self . schedule . AddTripObject ( trip , self . problems , True ) <EOL> self . trip = trip <EOL> def testNonOverlappingPeriods ( self ) : <EOL> headway_period1 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period2 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period3 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1000> , <EOL> } ) <EOL> headway_period4 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period1 . AddToSchedule ( self . schedule , self . problems ) <EOL> headway_period2 . AddToSchedule ( self . schedule , self . problems ) <EOL> headway_period3 . AddToSchedule ( self . schedule , self . problems ) <EOL> headway_period4 . AddToSchedule ( self . schedule , self . problems ) <EOL> self . trip . Validate ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . trip . ClearFrequencies ( ) <EOL> def testOverlappingPeriods ( self ) : <EOL> headway_period1 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period2 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period1 . AddToSchedule ( self . schedule , self . problems ) <EOL> headway_period2 . AddToSchedule ( self . schedule , self . problems ) <EOL> self . ValidateAndExpectOtherProblem ( self . trip ) <EOL> self . trip . ClearFrequencies ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testPeriodWithInvalidTripId ( self ) : <EOL> headway_period1 = transitfeed . Frequency ( { '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> headway_period1 . AddToSchedule ( self . schedule , self . problems ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , e . column_name ) <EOL> self . trip . ClearFrequencies ( ) <EOL> def testExactTimesStringValueConversion ( self ) : <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:0> ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:0> ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:0>" } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:0> ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1>" } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testExactTimesAsIntValue ( self ) : <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:0> ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:0> } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:0> ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:1> } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . assertEquals ( frequency . ExactTimes ( ) , <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testExactTimesInvalidValues ( self ) : <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:15> } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . accumulator . PopInvalidValue ( "<STR_LIT>" ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> frequency = transitfeed . Frequency ( <EOL> field_dict = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:yes>" } ) <EOL> frequency . ValidateBeforeAdd ( self . problems ) <EOL> self . accumulator . PopInvalidValue ( "<STR_LIT>" ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) </s>
