Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(102)

Side by Side Diff: python/test/testtransitfeed.py

Issue 75063: Adding validation for uniqueness of service_id X date in calendar_dates SVN Base: http://googletransitdatafeed.googlecode.com/svn/trunk/
Patch Set: Removing unnecessary linebreak Created 1 month, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python2.5 1 #!/usr/bin/python2.5
2 2
3 # Copyright (C) 2007 Google Inc. 3 # Copyright (C) 2007 Google Inc.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 3192 matching lines...) Expand 10 before | Expand all | Expand 10 after
3203 self.assertEqual("Bogus Stop (Demo)", e.stop_name) 3203 self.assertEqual("Bogus Stop (Demo)", e.stop_name)
3204 self.assertEqual("BOGUS", e.stop_id) 3204 self.assertEqual("BOGUS", e.stop_id)
3205 self.problems.AssertNoMoreExceptions() 3205 self.problems.AssertNoMoreExceptions()
3206 3206
3207 3207
3208 3208
3209 class OnlyCalendarDatesTestCase(LoadTestCase): 3209 class OnlyCalendarDatesTestCase(LoadTestCase):
3210 def runTest(self): 3210 def runTest(self):
3211 self.Load('only_calendar_dates'), 3211 self.Load('only_calendar_dates'),
3212 self.problems.AssertNoMoreExceptions() 3212 self.problems.AssertNoMoreExceptions()
3213
3214
3215 class DuplicateServiceIdDateWarningTestCase(MemoryZipTestCase):
3216 def runTest(self):
3217 # Two lines with the same value of service_id and date.
3218 # Test for the warning.
3219 self.zip.writestr(
3220 'calendar_dates.txt',
3221 'service_id,date,exception_type\n'
3222 'FULLW,20100604,1\n'
3223 'FULLW,20100604,2\n')
3224 schedule = self.loader.Load()
3225 e = self.problems.PopException('DuplicateID')
3226 self.assertEquals('(service_id, date)', e.column_name)
3227 self.assertEquals('(FULLW, 20100604)', e.value)
3213 3228
3214 3229
3215 class AddStopTimeParametersTestCase(unittest.TestCase): 3230 class AddStopTimeParametersTestCase(unittest.TestCase):
3216 def runTest(self): 3231 def runTest(self):
3217 problem_reporter = TestFailureProblemReporter(self) 3232 problem_reporter = TestFailureProblemReporter(self)
3218 schedule = transitfeed.Schedule(problem_reporter=problem_reporter) 3233 schedule = transitfeed.Schedule(problem_reporter=problem_reporter)
3219 route = schedule.AddRoute(short_name="10", long_name="", route_type="Bus") 3234 route = schedule.AddRoute(short_name="10", long_name="", route_type="Bus")
3220 stop = schedule.AddStop(40, -128, "My stop") 3235 stop = schedule.AddStop(40, -128, "My stop")
3221 # Stop must be added to schedule so that the call 3236 # Stop must be added to schedule so that the call
3222 # AddStopTime -> AddStopTimeObject -> GetStopTimes -> GetStop can work 3237 # AddStopTime -> AddStopTimeObject -> GetStopTimes -> GetStop can work
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4381 stoptimes = self.trip1.GetStopTimes() 4396 stoptimes = self.trip1.GetStopTimes()
4382 for stoptimes_clone in stoptimes_list: 4397 for stoptimes_clone in stoptimes_list:
4383 self.assertEqual(len(stoptimes_clone), len(stoptimes)) 4398 self.assertEqual(len(stoptimes_clone), len(stoptimes))
4384 for st_clone, st in zip(stoptimes_clone, stoptimes): 4399 for st_clone, st in zip(stoptimes_clone, stoptimes):
4385 for name in st.__slots__: 4400 for name in st.__slots__:
4386 if name not in ('arrival_secs', 'departure_secs'): 4401 if name not in ('arrival_secs', 'departure_secs'):
4387 self.assertEqual(getattr(st, name), getattr(st_clone, name)) 4402 self.assertEqual(getattr(st, name), getattr(st_clone, name))
4388 4403
4389 if __name__ == '__main__': 4404 if __name__ == '__main__':
4390 unittest.main() 4405 unittest.main()
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497