Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 6c2c887

Browse files
authored
Merge pull request #501 from laurentg/master
Fix #500 - validate if IDless agency is single.
2 parents 10efad5 + 71423df commit 6c2c887

File tree

9 files changed

+82
-0
lines changed

9 files changed

+82
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
agency_id,agency_name,agency_url,agency_timezone
2+
DTA,Demo Transit Authority,http://google.com,America/Los_Angeles
3+
,IDless Demo Transit Authority,http://google.com,America/Los_Angeles
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
2+
FULLW,1,1,1,1,1,1,1,20070101,20101231
3+
WE,0,0,0,0,0,1,1,20070101,20101231
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
service_id,date,exception_type
2+
FULLW,20070604,2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color
2+
AB,DTA,,Airport - Bullfrog,,3,,,
3+
BFC,DTA,,Bullfrog - Furnace Creek Resort,,3,,,
4+
STBA,,,Stagecoach - Airport Shuttle,,3,,,
5+
CITY,DTA,,City,,3,,,
6+
AAMV,DTA,,Airport - Amargosa Valley,,3,,,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type,shape_dist_traveled
2+
STBA,6:00:00,6:00:00,STAGECOACH,1,,,,
3+
STBA,6:20:00,6:20:00,BEATTY_AIRPORT,2,,,,
4+
CITY1,6:00:00,6:00:00,STAGECOACH,1,,,,
5+
CITY1,6:05:00,6:07:00,NANAA,2,,,,
6+
CITY1,6:12:00,6:14:00,NADAV,3,,,,
7+
CITY1,6:19:00,6:21:00,DADAN,4,,,,
8+
CITY1,6:26:00,6:28:00,EMSI,5,,,,
9+
CITY2,6:28:00,6:30:00,EMSI,1,,,,
10+
CITY2,6:35:00,6:37:00,DADAN,2,,,,
11+
CITY2,6:42:00,6:44:00,NADAV,3,,,,
12+
CITY2,6:49:00,6:51:00,NANAA,4,,,,
13+
CITY2,6:56:00,6:58:00,STAGECOACH,5,,,,
14+
AB1,8:00:00,8:00:00,BEATTY_AIRPORT,1,,,,
15+
AB1,8:10:00,8:15:00,BULLFROG,2,,,,
16+
AB2,12:05:00,12:05:00,BULLFROG,1,,,,
17+
AB2,12:15:00,12:15:00,BEATTY_AIRPORT,2,,,,
18+
BFC1,8:20:00,8:20:00,BULLFROG,1,,,,
19+
BFC1,9:20:00,9:20:00,FUR_CREEK_RES,2,,,,
20+
BFC2,11:00:00,11:00:00,FUR_CREEK_RES,1,,,,
21+
BFC2,12:00:00,12:00:00,BULLFROG,2,,,,
22+
AAMV1,8:00:00,8:00:00,BEATTY_AIRPORT,1,,,,
23+
AAMV1,9:00:00,9:00:00,AMV,2,,,,
24+
AAMV2,10:00:00,10:00:00,AMV,1,,,,
25+
AAMV2,11:00:00,11:00:00,BEATTY_AIRPORT,2,,,,
26+
AAMV3,13:00:00,13:00:00,BEATTY_AIRPORT,1,,,,
27+
AAMV3,14:00:00,14:00:00,AMV,2,,,,
28+
AAMV4,15:00:00,15:00:00,AMV,1,,,,
29+
AAMV4,16:00:00,16:00:00,BEATTY_AIRPORT,2,,,,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
stop_id,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url
2+
FUR_CREEK_RES,Furnace Creek Resort (Demo),,36.425288,-117.133162,,
3+
BEATTY_AIRPORT,Nye County Airport (Demo),,36.868446,-116.784582,,
4+
BULLFROG,Bullfrog (Demo),,36.88108,-116.81797,,
5+
STAGECOACH,Stagecoach Hotel & Casino (Demo),,36.915682,-116.751677,,
6+
NADAV,North Ave / D Ave N (Demo),,36.914893,-116.76821,,
7+
NANAA,North Ave / N A Ave (Demo),,36.914944,-116.761472,,
8+
DADAN,Doing Ave / D Ave N (Demo),,36.909489,-116.768242,,
9+
EMSI,E Main St / S Irving St (Demo),,36.905697,-116.76218,,
10+
AMV,Amargosa Valley (Demo),,36.641496,-116.40094,,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
route_id,service_id,trip_id,trip_headsign,direction_id,block_id,shape_id
2+
AB,FULLW,AB1,to Bullfrog,0,1,
3+
AB,FULLW,AB2,to Airport,1,2,
4+
STBA,FULLW,STBA,Shuttle,,,
5+
CITY,FULLW,CITY1,,0,,
6+
CITY,FULLW,CITY2,,1,,
7+
BFC,FULLW,BFC1,to Furnace Creek Resort,0,1,
8+
BFC,FULLW,BFC2,to Bullfrog,1,2,
9+
AAMV,WE,AAMV1,to Amargosa Valley,0,,
10+
AAMV,WE,AAMV2,to Airport,1,,
11+
AAMV,WE,AAMV3,to Amargosa Valley,0,,
12+
AAMV,WE,AAMV4,to Airport,1,,

tests/transitfeed/testtrip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,13 @@ def runTest(self):
615615
self.accumulator.AssertNoMoreExceptions()
616616

617617

618+
class InvalidAgencyIdsTestCase(util.LoadTestCase):
619+
def runTest(self):
620+
self.Load('invalid_agency_ids')
621+
self.accumulator.PopException('OtherProblem')
622+
self.accumulator.AssertNoMoreExceptions()
623+
624+
618625
class AddStopTimeParametersTestCase(util.TestCase):
619626
def runTest(self):
620627
problem_reporter = util.GetTestFailureProblemReporter(self)

transitfeed/schedule.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,15 @@ def ValidateBlocks(self, problems, trip_intervals_by_block_id):
12781278
trip_b.trip_id,
12791279
block_id)
12801280

1281+
def ValidateIdlessAgency(self, problems):
1282+
# Check that only one agency is IDless
1283+
if len(self._agencies) > 1:
1284+
for agency in self._agencies.values():
1285+
if util.IsEmpty(agency.agency_id):
1286+
problems.OtherProblem('Agency "%s" does not have an ID. '
1287+
'This is only allowed if a single agency is defined, '
1288+
'whereas there are %d in total.' % (agency.agency_name, len(self._agencies)))
1289+
12811290
def ValidateRouteAgencyId(self, problems):
12821291
# Check that routes' agency IDs are valid, if set
12831292
for route in self.routes.values():
@@ -1346,6 +1355,7 @@ def Validate(self,
13461355
self.ValidateNearbyStops(problems)
13471356
self.ValidateRouteNames(problems, validate_children)
13481357
self.ValidateTrips(problems)
1358+
self.ValidateIdlessAgency(problems)
13491359
self.ValidateRouteAgencyId(problems)
13501360
self.ValidateTripStopTimes(problems)
13511361
self.ValidateUnusedShapes(problems)

0 commit comments

Comments
 (0)