<s> from __future__ import absolute_import <EOL> from datetime import date <EOL> import re <EOL> from tests import util <EOL> import time <EOL> import transitfeed <EOL> class DuplicateStopTestCase ( util . TestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( <EOL> problem_reporter = util . ExceptionProblemReporterNoExpiration ( ) ) <EOL> try : <EOL> schedule . Load ( util . DataPath ( '<STR_LIT>' ) , extra_validation = True ) <EOL> self . fail ( '<STR_LIT>' ) <EOL> except transitfeed . OtherProblem : <EOL> pass <EOL> class DuplicateScheduleIDTestCase ( util . TestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( <EOL> problem_reporter = util . ExceptionProblemReporterNoExpiration ( ) ) <EOL> try : <EOL> schedule . Load ( util . DataPath ( '<STR_LIT>' ) , <EOL> extra_validation = True ) <EOL> self . fail ( '<STR_LIT>' ) <EOL> except transitfeed . DuplicateID : <EOL> pass <EOL> class OverlappingBlockSchedule ( transitfeed . Schedule ) : <EOL> """<STR_LIT>""" <EOL> _get_service_period_call_count = <NUM_LIT:0> <EOL> def GetServicePeriod ( self , service_id ) : <EOL> self . _get_service_period_call_count += <NUM_LIT:1> <EOL> return transitfeed . Schedule . GetServicePeriod ( self , service_id ) <EOL> def GetServicePeriodCallCount ( self ) : <EOL> return self . _get_service_period_call_count <EOL> class OverlappingBlockTripsTestCase ( util . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . accumulator = util . RecordingProblemAccumulator ( <EOL> self , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . problems = transitfeed . ProblemReporter ( self . accumulator ) <EOL> schedule = OverlappingBlockSchedule ( problem_reporter = self . problems ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> sp1 = transitfeed . ServicePeriod ( "<STR_LIT>" ) <EOL> sp1 . SetWeekdayService ( True ) <EOL> sp1 . SetStartDate ( "<STR_LIT>" ) <EOL> sp1 . SetEndDate ( "<STR_LIT>" ) <EOL> schedule . AddServicePeriodObject ( sp1 ) <EOL> sp2 = transitfeed . ServicePeriod ( "<STR_LIT>" ) <EOL> sp2 . SetDayOfWeekHasService ( <NUM_LIT:0> ) <EOL> sp2 . SetDayOfWeekHasService ( <NUM_LIT:2> ) <EOL> sp2 . SetDayOfWeekHasService ( <NUM_LIT:4> ) <EOL> sp2 . SetStartDate ( "<STR_LIT>" ) <EOL> sp2 . SetEndDate ( "<STR_LIT>" ) <EOL> schedule . AddServicePeriodObject ( sp2 ) <EOL> sp3 = transitfeed . ServicePeriod ( "<STR_LIT>" ) <EOL> sp3 . SetWeekendService ( True ) <EOL> sp3 . SetStartDate ( "<STR_LIT>" ) <EOL> sp3 . SetEndDate ( "<STR_LIT>" ) <EOL> schedule . AddServicePeriodObject ( sp3 ) <EOL> self . stop1 = schedule . AddStop ( lng = - <NUM_LIT> , <EOL> lat = <NUM_LIT> , <EOL> name = "<STR_LIT>" , <EOL> stop_id = "<STR_LIT>" ) <EOL> self . stop2 = schedule . AddStop ( lng = - <NUM_LIT> , <EOL> lat = <NUM_LIT> , <EOL> name = "<STR_LIT>" , <EOL> stop_id = "<STR_LIT>" ) <EOL> self . route = schedule . AddRoute ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , route_id = "<STR_LIT>" ) <EOL> self . schedule = schedule <EOL> self . sp1 = sp1 <EOL> self . sp2 = sp2 <EOL> self . sp3 = sp3 <EOL> def testNoOverlap ( self ) : <EOL> schedule , route , sp1 = self . schedule , self . route , self . sp1 <EOL> trip1 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip1 . block_id = "<STR_LIT>" <EOL> trip1 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip2 . block_id = "<STR_LIT>" <EOL> trip2 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> schedule . Validate ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testOverlapSameServicePeriod ( self ) : <EOL> schedule , route , sp1 = self . schedule , self . route , self . sp1 <EOL> trip1 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip1 . block_id = "<STR_LIT>" <EOL> trip1 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip2 . block_id = "<STR_LIT>" <EOL> trip2 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> schedule . Validate ( self . problems ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id1 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id2 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . block_id , '<STR_LIT>' ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testOverlapDifferentServicePeriods ( self ) : <EOL> schedule , route , sp1 , sp2 = self . schedule , self . route , self . sp1 , self . sp2 <EOL> trip1 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip1 . block_id = "<STR_LIT>" <EOL> trip1 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 = route . AddTrip ( schedule , service_period = sp2 , trip_id = "<STR_LIT>" ) <EOL> trip2 . block_id = "<STR_LIT>" <EOL> trip2 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip3 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip3 . block_id = "<STR_LIT>" <EOL> trip3 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip3 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip4 = route . AddTrip ( schedule , service_period = sp2 , trip_id = "<STR_LIT>" ) <EOL> trip4 . block_id = "<STR_LIT>" <EOL> trip4 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip4 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> schedule . Validate ( self . problems ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id1 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id2 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . block_id , '<STR_LIT>' ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id1 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . trip_id2 , '<STR_LIT>' ) <EOL> self . assertEqual ( e . block_id , '<STR_LIT>' ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . assertEquals ( <NUM_LIT:2> , schedule . GetServicePeriodCallCount ( ) ) <EOL> def testNoOverlapDifferentServicePeriods ( self ) : <EOL> schedule , route , sp1 , sp3 = self . schedule , self . route , self . sp1 , self . sp3 <EOL> trip1 = route . AddTrip ( schedule , service_period = sp1 , trip_id = "<STR_LIT>" ) <EOL> trip1 . block_id = "<STR_LIT>" <EOL> trip1 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 = route . AddTrip ( schedule , service_period = sp3 , trip_id = "<STR_LIT>" ) <EOL> trip2 . block_id = "<STR_LIT>" <EOL> trip2 . AddStopTime ( self . stop2 , stop_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( self . stop1 , stop_time = "<STR_LIT>" ) <EOL> schedule . Validate ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class StopsNearEachOther ( util . MemoryZipTestCase ) : <EOL> def testTooNear ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> schedule = self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testJustFarEnough ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> schedule = self . MakeLoaderAndLoad ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testSameLocation ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> schedule = self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testStationsTooNear ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> schedule = self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testStopNearNonParentStation ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> schedule = self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> fmt = e . FormatProblem ( ) <EOL> self . assertTrue ( re . search ( <EOL> r"<STR_LIT>" , <EOL> fmt ) , fmt ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class NoServiceExceptionsTestCase ( util . MemoryZipTestCase ) : <EOL> def testNoCalendarDates ( self ) : <EOL> self . RemoveArchive ( "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testNoExceptionsWhenFeedActiveForShortPeriodOfTime ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . RemoveArchive ( "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testEmptyCalendarDates ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testCalendarDatesWithHeaderOnly ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testCalendarDatesWithAddedServiceException ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testCalendarDatesWithRemovedServiceException ( self ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class GetServicePeriodsActiveEachDateTestCase ( util . TestCase ) : <EOL> def testEmpty ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> self . assertEquals ( <EOL> [ ] , <EOL> schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) ) <EOL> self . assertEquals ( <EOL> [ ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , [ ] ) , ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , [ ] ) ] , <EOL> schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> def testOneService ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> sp1 = transitfeed . ServicePeriod ( ) <EOL> sp1 . service_id = "<STR_LIT>" <EOL> sp1 . SetDateHasService ( "<STR_LIT>" ) <EOL> sp1 . SetDateHasService ( "<STR_LIT>" ) <EOL> schedule . AddServicePeriodObject ( sp1 ) <EOL> self . assertEquals ( <EOL> [ ] , <EOL> schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) ) <EOL> self . assertEquals ( <EOL> [ ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , [ ] ) , ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , [ sp1 ] ) ] , <EOL> schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> def testTwoService ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> sp1 = transitfeed . ServicePeriod ( ) <EOL> sp1 . service_id = "<STR_LIT>" <EOL> sp1 . SetDateHasService ( "<STR_LIT>" ) <EOL> sp1 . SetDateHasService ( "<STR_LIT>" ) <EOL> schedule . AddServicePeriodObject ( sp1 ) <EOL> sp2 = transitfeed . ServicePeriod ( ) <EOL> sp2 . service_id = "<STR_LIT>" <EOL> sp2 . SetStartDate ( "<STR_LIT>" ) <EOL> sp2 . SetEndDate ( "<STR_LIT>" ) <EOL> sp2 . SetWeekendService ( ) <EOL> sp2 . SetWeekdayService ( ) <EOL> schedule . AddServicePeriodObject ( sp2 ) <EOL> self . assertEquals ( <EOL> [ ] , <EOL> schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) ) <EOL> date_services = schedule . GetServicePeriodsActiveEachDate ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , <EOL> date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertEquals ( <EOL> [ date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ] , [ d for d , _ in date_services ] ) <EOL> self . assertEquals ( set ( [ sp1 , sp2 ] ) , set ( date_services [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) ) <EOL> self . assertEquals ( [ sp1 ] , date_services [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> class DuplicateTripTestCase ( util . ValidationTestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( self . problems ) <EOL> schedule . _check_duplicate_trips = True ; <EOL> agency = transitfeed . Agency ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> schedule . AddAgencyObject ( agency ) <EOL> service = schedule . GetDefaultServicePeriod ( ) <EOL> service . SetDateHasService ( '<STR_LIT>' ) <EOL> route1 = transitfeed . Route ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:3> , '<STR_LIT>' , '<STR_LIT>' ) <EOL> schedule . AddRouteObject ( route1 ) <EOL> route2 = transitfeed . Route ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:3> , '<STR_LIT>' , '<STR_LIT>' ) <EOL> schedule . AddRouteObject ( route2 ) <EOL> trip1 = transitfeed . Trip ( ) <EOL> trip1 . route_id = '<STR_LIT>' <EOL> trip1 . trip_id = '<STR_LIT>' <EOL> trip1 . trip_headsign = '<STR_LIT>' <EOL> trip1 . direction_id = '<STR_LIT:0>' <EOL> trip1 . service_id = service . service_id <EOL> schedule . AddTripObject ( trip1 ) <EOL> trip2 = transitfeed . Trip ( ) <EOL> trip2 . route_id = '<STR_LIT>' <EOL> trip2 . trip_id = '<STR_LIT>' <EOL> trip2 . trip_headsign = '<STR_LIT>' <EOL> trip2 . direction_id = '<STR_LIT:0>' <EOL> trip2 . service_id = service . service_id <EOL> schedule . AddTripObject ( trip2 ) <EOL> trip3 = transitfeed . Trip ( ) <EOL> trip3 . route_id = '<STR_LIT>' <EOL> trip3 . trip_id = '<STR_LIT>' <EOL> trip3 . trip_headsign = '<STR_LIT>' <EOL> trip3 . direction_id = '<STR_LIT:0>' <EOL> trip3 . service_id = service . service_id <EOL> schedule . AddTripObject ( trip3 ) <EOL> stop1 = transitfeed . Stop ( <NUM_LIT> , - <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" ) <EOL> schedule . AddStopObject ( stop1 ) <EOL> trip1 . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:0> , shape_dist_traveled = <NUM_LIT:0> ) <EOL> trip2 . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:0> , shape_dist_traveled = <NUM_LIT:0> ) <EOL> trip3 . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:0> , shape_dist_traveled = <NUM_LIT:0> ) <EOL> stop2 = transitfeed . Stop ( <NUM_LIT> , - <NUM_LIT> , "<STR_LIT>" , "<STR_LIT>" ) <EOL> schedule . AddStopObject ( stop2 ) <EOL> trip1 . AddStopTime ( stop2 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:1> , shape_dist_traveled = <NUM_LIT:1> ) <EOL> trip2 . AddStopTime ( stop2 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:1> , shape_dist_traveled = <NUM_LIT:1> ) <EOL> trip3 . AddStopTime ( stop2 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" , <EOL> stop_sequence = <NUM_LIT:1> , shape_dist_traveled = <NUM_LIT:1> ) <EOL> schedule . Validate ( self . problems ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( '<STR_LIT>' ) != - <NUM_LIT:1> ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( '<STR_LIT>' ) != - <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class StopBelongsToBothSubwayAndBusTestCase ( util . ValidationTestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( self . problems ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> route1 = schedule . AddRoute ( short_name = "<STR_LIT>" , long_name = "<STR_LIT>" , <EOL> route_type = <NUM_LIT:3> ) <EOL> route2 = schedule . AddRoute ( short_name = "<STR_LIT>" , long_name = "<STR_LIT>" , <EOL> route_type = <NUM_LIT:1> ) <EOL> service = schedule . GetDefaultServicePeriod ( ) <EOL> service . SetDateHasService ( "<STR_LIT>" ) <EOL> trip1 = route1 . AddTrip ( schedule , "<STR_LIT>" , service , "<STR_LIT>" ) <EOL> trip2 = route2 . AddTrip ( schedule , "<STR_LIT>" , service , "<STR_LIT>" ) <EOL> stop1 = schedule . AddStop ( <NUM_LIT> , - <NUM_LIT> , "<STR_LIT>" ) <EOL> stop2 = schedule . AddStop ( <NUM_LIT> , - <NUM_LIT> , "<STR_LIT>" ) <EOL> stop3 = schedule . AddStop ( <NUM_LIT> , - <NUM_LIT> , "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> trip1 . AddStopTime ( stop2 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> trip2 . AddStopTime ( stop3 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> schedule . Validate ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . assertTrue ( e . FormatProblem ( ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class UnusedStopAgencyTestCase ( util . LoadTestCase ) : <EOL> def runTest ( self ) : <EOL> self . Load ( '<STR_LIT>' ) , <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , e . stop_name ) <EOL> self . assertEqual ( "<STR_LIT>" , e . stop_id ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class ScheduleStartAndExpirationDatesTestCase ( util . MemoryZipTestCase ) : <EOL> _IGNORE_TYPES = util . MemoryZipTestCase . _IGNORE_TYPES [ : ] <EOL> _IGNORE_TYPES . remove ( "<STR_LIT>" ) <EOL> now = time . mktime ( time . localtime ( ) ) <EOL> seconds_per_day = <NUM_LIT> * <NUM_LIT> * <NUM_LIT> <EOL> date_format = "<STR_LIT>" <EOL> two_weeks_ago = time . strftime ( date_format , <EOL> time . localtime ( now - <NUM_LIT> * seconds_per_day ) ) <EOL> one_week_ago = time . strftime ( date_format , <EOL> time . localtime ( now - <NUM_LIT:7> * seconds_per_day ) ) <EOL> one_week = time . strftime ( date_format , <EOL> time . localtime ( now + <NUM_LIT:7> * seconds_per_day ) ) <EOL> two_weeks = time . strftime ( date_format , <EOL> time . localtime ( now + <NUM_LIT> * seconds_per_day ) ) <EOL> two_months = time . strftime ( date_format , <EOL> time . localtime ( now + <NUM_LIT> * seconds_per_day ) ) <EOL> def prepareArchiveContents ( self , calendar_start , calendar_end , <EOL> exception_date , feed_info_start , feed_info_end ) : <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( calendar_start , calendar_end , <EOL> calendar_start , calendar_end ) ) <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( exception_date ) ) <EOL> from_column = "<STR_LIT>" <EOL> if feed_info_start : <EOL> from_column = "<STR_LIT>" <EOL> feed_info_start = "<STR_LIT:U+002C>" + feed_info_start <EOL> until_column = "<STR_LIT>" <EOL> if feed_info_end : <EOL> until_column = "<STR_LIT>" <EOL> feed_info_end = "<STR_LIT:U+002C>" + feed_info_end <EOL> self . SetArchiveContents ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( <EOL> from_column , until_column , feed_info_start , feed_info_end ) ) <EOL> def testNoErrors ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . two_months , <EOL> self . two_weeks , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testExpirationDateCausedByServicePeriod ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . two_weeks , <EOL> self . one_week , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . expiration_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . two_weeks , <EOL> self . one_week , <EOL> self . two_weeks_ago , self . two_months ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testFutureServiceCausedByServicePeriod ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . one_week , self . two_months , <EOL> self . two_weeks , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . start_date_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . prepareArchiveContents ( <EOL> self . one_week , self . two_months , <EOL> self . two_weeks , <EOL> self . two_weeks_ago , self . two_months ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testExpirationDateCausedByServicePeriodDateException ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . one_week , <EOL> self . two_weeks , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . expiration_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . one_week , <EOL> self . two_weeks , <EOL> self . two_weeks_ago , self . two_months ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testFutureServiceCausedByServicePeriodDateException ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks , self . two_months , <EOL> self . one_week , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . start_date_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks , self . two_months , <EOL> self . one_week , <EOL> self . two_weeks_ago , self . two_months ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testExpirationDateCausedByFeedInfo ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . two_months , <EOL> self . one_week , <EOL> "<STR_LIT>" , self . two_weeks ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . expiration_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> def testFutureServiceCausedByFeedInfo ( self ) : <EOL> self . prepareArchiveContents ( <EOL> self . two_weeks_ago , self . two_months , <EOL> self . one_week_ago , <EOL> self . one_week , self . two_months ) <EOL> self . MakeLoaderAndLoad ( self . problems ) <EOL> e = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in e . start_date_origin_file ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class DuplicateStopValidationTestCase ( util . ValidationTestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( problem_reporter = self . problems ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> route = transitfeed . Route ( ) <EOL> route . route_id = "<STR_LIT>" <EOL> route . route_type = <NUM_LIT:3> <EOL> route . route_long_name = "<STR_LIT>" <EOL> schedule . AddRouteObject ( route ) <EOL> service_period = transitfeed . ServicePeriod ( "<STR_LIT>" ) <EOL> service_period . SetStartDate ( "<STR_LIT>" ) <EOL> service_period . SetEndDate ( "<STR_LIT>" ) <EOL> service_period . SetWeekdayService ( True ) <EOL> schedule . AddServicePeriodObject ( service_period ) <EOL> trip = transitfeed . Trip ( ) <EOL> trip . route_id = "<STR_LIT>" <EOL> trip . service_id = "<STR_LIT>" <EOL> trip . trip_id = "<STR_LIT>" <EOL> schedule . AddTripObject ( trip ) <EOL> stop1 = transitfeed . Stop ( ) <EOL> stop1 . stop_id = "<STR_LIT>" <EOL> stop1 . stop_name = "<STR_LIT>" <EOL> stop1 . stop_lat = <NUM_LIT> <EOL> stop1 . stop_lon = <NUM_LIT> <EOL> schedule . AddStopObject ( stop1 ) <EOL> trip . AddStopTime ( stop1 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> stop2 = transitfeed . Stop ( ) <EOL> stop2 . stop_id = "<STR_LIT>" <EOL> stop2 . stop_name = "<STR_LIT>" <EOL> stop2 . stop_lat = <NUM_LIT> <EOL> stop2 . stop_lon = <NUM_LIT> <EOL> schedule . AddStopObject ( stop2 ) <EOL> trip . AddStopTime ( stop2 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> schedule . Validate ( ) <EOL> stop3 = transitfeed . Stop ( ) <EOL> stop3 . stop_id = "<STR_LIT>" <EOL> stop3 . stop_name = "<STR_LIT>" <EOL> stop3 . stop_lat = <NUM_LIT> <EOL> stop3 . stop_lon = <NUM_LIT> <EOL> schedule . AddStopObject ( stop3 ) <EOL> trip . AddStopTime ( stop3 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> schedule . Validate ( ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> stop4 = transitfeed . Stop ( ) <EOL> stop4 . stop_id = "<STR_LIT>" <EOL> stop4 . stop_name = "<STR_LIT>" <EOL> stop4 . stop_lat = <NUM_LIT> <EOL> stop4 . stop_lon = <NUM_LIT> <EOL> schedule . AddStopObject ( stop4 ) <EOL> trip . AddStopTime ( stop4 , arrival_time = "<STR_LIT>" , departure_time = "<STR_LIT>" ) <EOL> schedule . Validate ( ) <EOL> e = self . accumulator . PopException ( '<STR_LIT>' ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) <EOL> class DuplicateTripIDValidationTestCase ( util . TestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( <EOL> problem_reporter = util . ExceptionProblemReporterNoExpiration ( ) ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> route = transitfeed . Route ( ) <EOL> route . route_id = "<STR_LIT>" <EOL> route . route_type = <NUM_LIT:3> <EOL> route . route_long_name = "<STR_LIT>" <EOL> schedule . AddRouteObject ( route ) <EOL> service_period = transitfeed . ServicePeriod ( "<STR_LIT>" ) <EOL> service_period . SetStartDate ( "<STR_LIT>" ) <EOL> service_period . SetEndDate ( "<STR_LIT>" ) <EOL> service_period . SetWeekdayService ( True ) <EOL> schedule . AddServicePeriodObject ( service_period ) <EOL> trip1 = transitfeed . Trip ( ) <EOL> trip1 . route_id = "<STR_LIT>" <EOL> trip1 . service_id = "<STR_LIT>" <EOL> trip1 . trip_id = "<STR_LIT>" <EOL> schedule . AddTripObject ( trip1 ) <EOL> trip2 = transitfeed . Trip ( ) <EOL> trip2 . route_id = "<STR_LIT>" <EOL> trip2 . service_id = "<STR_LIT>" <EOL> trip2 . trip_id = "<STR_LIT>" <EOL> try : <EOL> schedule . AddTripObject ( trip2 ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except transitfeed . DuplicateID , e : <EOL> self . assertEqual ( "<STR_LIT>" , e . column_name ) <EOL> self . assertEqual ( "<STR_LIT>" , e . value ) <EOL> class AgencyIDValidationTestCase ( util . TestCase ) : <EOL> def runTest ( self ) : <EOL> schedule = transitfeed . Schedule ( <EOL> problem_reporter = util . ExceptionProblemReporterNoExpiration ( ) ) <EOL> route = transitfeed . Route ( ) <EOL> route . route_id = "<STR_LIT>" <EOL> route . route_type = <NUM_LIT:3> <EOL> route . route_long_name = "<STR_LIT>" <EOL> try : <EOL> schedule . AddRouteObject ( route ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except transitfeed . InvalidValue , e : <EOL> self . assertEqual ( '<STR_LIT>' , e . column_name ) <EOL> self . assertEqual ( None , e . value ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> schedule . AddRouteObject ( route ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> route = transitfeed . Route ( ) <EOL> route . route_id = "<STR_LIT>" <EOL> route . route_type = <NUM_LIT:3> <EOL> route . route_long_name = "<STR_LIT>" <EOL> try : <EOL> schedule . AddRouteObject ( route ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except transitfeed . InvalidValue , e : <EOL> self . assertEqual ( '<STR_LIT>' , e . column_name ) <EOL> self . assertEqual ( None , e . value ) <EOL> schedule . AddAgency ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> schedule . AddRouteObject ( route ) <EOL> class DefaultAgencyTestCase ( util . TestCase ) : <EOL> def freeAgency ( self , ex = '<STR_LIT>' ) : <EOL> agency = transitfeed . Agency ( ) <EOL> agency . agency_id = '<STR_LIT>' + ex <EOL> agency . agency_name = '<STR_LIT>' + ex <EOL> agency . agency_url = '<STR_LIT>' + ex <EOL> agency . agency_timezone = '<STR_LIT>' <EOL> return agency <EOL> def test_SetDefault ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency = self . freeAgency ( ) <EOL> schedule . SetDefaultAgency ( agency ) <EOL> self . assertEqual ( agency , schedule . GetDefaultAgency ( ) ) <EOL> def test_NewDefaultAgency ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency1 = schedule . NewDefaultAgency ( ) <EOL> self . assertTrue ( agency1 . agency_id ) <EOL> self . assertEqual ( agency1 . agency_id , schedule . GetDefaultAgency ( ) . agency_id ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( schedule . GetAgencyList ( ) ) ) <EOL> agency2 = schedule . NewDefaultAgency ( ) <EOL> self . assertTrue ( agency2 . agency_id ) <EOL> self . assertEqual ( agency2 . agency_id , schedule . GetDefaultAgency ( ) . agency_id ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( schedule . GetAgencyList ( ) ) ) <EOL> self . assertNotEqual ( agency1 , agency2 ) <EOL> self . assertNotEqual ( agency1 . agency_id , agency2 . agency_id ) <EOL> agency3 = schedule . NewDefaultAgency ( agency_id = '<STR_LIT>' , <EOL> agency_name = '<STR_LIT>' , <EOL> agency_url = '<STR_LIT>' ) <EOL> self . assertEqual ( agency3 . agency_id , '<STR_LIT>' ) <EOL> self . assertEqual ( agency3 . agency_name , '<STR_LIT>' ) <EOL> self . assertEqual ( agency3 . agency_url , '<STR_LIT>' ) <EOL> self . assertEqual ( agency3 , schedule . GetDefaultAgency ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , schedule . GetDefaultAgency ( ) . agency_id ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( schedule . GetAgencyList ( ) ) ) <EOL> def test_NoAgencyMakeNewDefault ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency = schedule . GetDefaultAgency ( ) <EOL> self . assertTrue ( isinstance ( agency , transitfeed . Agency ) ) <EOL> self . assertTrue ( agency . agency_id ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( schedule . GetAgencyList ( ) ) ) <EOL> self . assertEqual ( agency , schedule . GetAgencyList ( ) [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( agency . agency_id , schedule . GetAgencyList ( ) [ <NUM_LIT:0> ] . agency_id ) <EOL> def test_AssumeSingleAgencyIsDefault ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency1 = self . freeAgency ( ) <EOL> schedule . AddAgencyObject ( agency1 ) <EOL> agency2 = self . freeAgency ( '<STR_LIT:2>' ) <EOL> self . assertEqual ( agency1 , schedule . GetDefaultAgency ( ) ) <EOL> def test_MultipleAgencyCausesNoDefault ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency1 = self . freeAgency ( ) <EOL> schedule . AddAgencyObject ( agency1 ) <EOL> agency2 = self . freeAgency ( '<STR_LIT:2>' ) <EOL> schedule . AddAgencyObject ( agency2 ) <EOL> self . assertEqual ( None , schedule . GetDefaultAgency ( ) ) <EOL> def test_OverwriteExistingAgency ( self ) : <EOL> schedule = transitfeed . Schedule ( ) <EOL> agency1 = self . freeAgency ( ) <EOL> agency1 . agency_id = '<STR_LIT:1>' <EOL> schedule . AddAgencyObject ( agency1 ) <EOL> agency2 = schedule . NewDefaultAgency ( ) <EOL> self . assertEqual ( agency1 , schedule . GetAgency ( agency1 . agency_id ) ) <EOL> self . assertNotEqual ( '<STR_LIT:1>' , agency2 . agency_id ) <EOL> class ServiceGapsTestCase ( util . MemoryZipTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ServiceGapsTestCase , self ) . setUp ( ) <EOL> self . SetArchiveContents ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . SetArchiveContents ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . SetArchiveContents ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . SetArchiveContents ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . schedule = self . MakeLoaderAndLoad ( extra_validation = False ) <EOL> def testServiceGapBeforeTodayIsDiscovered ( self ) : <EOL> self . schedule . Validate ( today = date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> service_gap_interval = <NUM_LIT> ) <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT:5> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> exception . last_day_without_service ) <EOL> self . AssertCommonExceptions ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> ) ) <EOL> def testNoServiceGapBeforeTodayIfTodayHasService ( self ) : <EOL> self . schedule . Validate ( today = date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> service_gap_interval = <NUM_LIT> ) <EOL> self . AssertCommonExceptions ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> ) ) <EOL> def testNoServiceGapBeforeTodayIfTheFeedStartsToday ( self ) : <EOL> self . schedule . Validate ( today = date ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:6> , <NUM_LIT:0> <NUM_LIT:1> ) , <EOL> service_gap_interval = <NUM_LIT> ) <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:11> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> exception . last_day_without_service ) <EOL> self . AssertCommonExceptions ( None ) <EOL> def testGapAtTheEndOfTheOneYearPeriodIsDiscovered ( self ) : <EOL> self . schedule . Validate ( today = date ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:6> , <NUM_LIT> ) , <EOL> service_gap_interval = <NUM_LIT> ) <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:11> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> exception . last_day_without_service ) <EOL> self . AssertCommonExceptions ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> ) ) <EOL> def testCurrentServiceGapIsDiscovered ( self ) : <EOL> self . schedule . Validate ( today = date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:30> ) , <EOL> service_gap_interval = <NUM_LIT> ) <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> ) , <EOL> exception . last_day_without_service ) <EOL> self . AssertCommonExceptions ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> ) ) <EOL> def AssertCommonExceptions ( self , last_exception_date ) : <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT:10> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT> ) , <EOL> exception . last_day_without_service ) <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:15> ) , <EOL> exception . last_day_without_service ) <EOL> if last_exception_date is not None : <EOL> exception = self . accumulator . PopException ( "<STR_LIT>" ) <EOL> self . assertEquals ( date ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:7> ) , <EOL> exception . first_day_without_service ) <EOL> self . assertEquals ( last_exception_date , <EOL> exception . last_day_without_service ) <EOL> self . accumulator . AssertNoMoreExceptions ( ) </s>
