# Path: tests/util.py
# def check_call(cmd, expected_retcode=0, stdin_str="", **kwargs):
# def DataPath(path):
# def GetDataPathContents():
#   def assertMatchesRegex(self, regex, string):
#   def setUp(self):
#   def tearDown(self):
#   def setUp(self):
#   def GetExamplePath(self, name):
#   def GetTestDataPath(self, *path):
#   def GetPath(self, *path):
#   def setUp(self):
#   def tearDown(self):
#   def CheckCallWithPath(self, cmd, expected_retcode=0, stdin_str=""):
#   def ConvertZipToDict(self, zip):
#   def ConvertDictToZip(self, dict):
#   def setUp(self):
#   def tearDown(self):
#   def setUp(self):
#   def MakeLoaderAndLoad(self,
#                         problems=None,
#                         extra_validation=True,
#                         gtfs_factory=None):
#   def AppendToArchiveContents(self, arcname, s):
#   def SetArchiveContents(self, arcname, contents):
#   def GetArchiveContents(self, arcname):
#   def RemoveArchive(self, arcname):
#   def GetArchiveNames(self):
#   def CreateZip(self):
#   def DumpZipFile(self, zf):
#   def setUp(self):
#   def Load(self, feed_name):
#   def ExpectInvalidValue(self, feed_name, column_name):
#   def ExpectMissingFile(self, feed_name, file_name):
#   def setUp(self):
#   def tearDown(self):
#   def ExpectNoProblems(self, object):
#   def ValidateAndExpectMissingValue(self, object, column_name):
#   def ExpectMissingValueInClosure(self, column_name, c):
#   def ValidateAndExpectInvalidValue(self, object, column_name,
#                                     value=INVALID_VALUE):
#   def ExpectInvalidValueInClosure(self, column_name, value=INVALID_VALUE,
#                                   c=None):
#   def ValidateAndExpectInvalidFloatValue(self, object, value):
#   def ValidateAndExpectOtherProblem(self, object):
#   def ExpectOtherProblemInClosure(self, c):
#   def ValidateAndExpectDateOutsideValidRange(self, object, column_name,
#                                              value=INVALID_VALUE):
#   def ExpectException(self, type_name, column_name=None, value=INVALID_VALUE):
#   def SimpleSchedule(self):
#   def __init__(self, test_case, ignore_types=None):
#   def _Report(self, e):
#   def PopException(self, type_name):
#   def FormatException(self, exce, tb):
#   def TearDownAssertNoMoreExceptions(self):
#   def AssertNoMoreExceptions(self):
#   def PopColumnSpecificException(self, type_name, column_name, file_name=None):
#   def PopInvalidValue(self, column_name, file_name=None):
#   def PopMissingValue(self, column_name, file_name=None):
#   def PopDateOutsideValidRange(self, column_name, file_name=None):
#   def PopDuplicateColumn(self, file_name, header, count):
#   def _SortExceptionGroups(self):
#     def ProcessExceptionGroup():
#   def __init__(self, test_case, ignore_types=("ExpirationDate",)):
#   def _Report(self, e):
# def GetTestFailureProblemReporter(test_case,
#                                   ignore_types=("ExpirationDate",)):
#   def __init__(self):
#   def ExpirationDate(self, expiration, context=None):
# class TestCase(unittest.TestCase):
# class RedirectStdOutTestCaseBase(TestCase):
# class GetPathTestCase(TestCase):
# class TempDirTestCaseBase(GetPathTestCase):
# class TempFileTestCaseBase(TestCase):
# class MemoryZipTestCase(TestCase):
# class LoadTestCase(TestCase):
# class ValidationTestCase(TestCase):
# class RecordingProblemAccumulator(transitfeed.ProblemAccumulatorInterface):
# class TestFailureProblemAccumulator(transitfeed.ProblemAccumulatorInterface):
# class ExceptionProblemReporterNoExpiration(transitfeed.ProblemReporter):
#   _IGNORE_TYPES = ["ExpirationDate"]
# INVALID_VALUE = Exception()


from tests import util
import transitfeed
                            " ".join(r.route_id for r in route_list))
    self.assertEqual("Long Name,,,GooCar,LNR",
                     ",".join(r.route_long_name for r in route_list))

  def testTripIdConflict(self):
    problems = util.GetTestFailureProblemReporter(self)
    schedule = transitfeed.Schedule(problem_reporter=problems)
    service_period = schedule.GetDefaultServicePeriod()
    service_period.SetDateHasService("20070101")
    route = schedule.AddRoute("0", "Long Name", "Bus")
    route.AddTrip()
    route.AddTrip(schedule=schedule, headsign="hs1",
                  service_period=service_period, trip_id="1")
    route.AddTrip(schedule, "hs2", service_period, "2")
    route.AddTrip(trip_id="4")
    route.AddTrip()  # This will be given a random trip_id
    trip_list = sorted(schedule.GetTripList(), key=lambda t: int(t.trip_id))
    self.assertMatchesRegex("0 1 2 4 \d{7,9}",
                            " ".join(t.trip_id for t in trip_list))
    self.assertEqual(",hs1,hs2,,",
                     ",".join(t["trip_headsign"] for t in trip_list))
    for t in trip_list:
      self.assertEqual(service_period.service_id, t.service_id)
      self.assertEqual(route.route_id, t.route_id)


class WriteSampleFeedTestCase(util.TempFileTestCaseBase):
  def assertEqualTimeString(self, a, b):
    """Assert that a and b are equal, even if they don't have the same zero
    padding on the hour. IE 08:45:00 vs 8:45:00."""

# Path: tests/util.py
# def check_call(cmd, expected_retcode=0, stdin_str="", **kwargs):
# def DataPath(path):
# def GetDataPathContents():
#   def assertMatchesRegex(self, regex, string):
#   def setUp(self):
#   def tearDown(self):
#   def setUp(self):
#   def GetExamplePath(self, name):
#   def GetTestDataPath(self, *path):
#   def GetPath(self, *path):
#   def setUp(self):
#   def tearDown(self):
#   def CheckCallWithPath(self, cmd, expected_retcode=0, stdin_str=""):
#   def ConvertZipToDict(self, zip):
#   def ConvertDictToZip(self, dict):
#   def setUp(self):
#   def tearDown(self):
#   def setUp(self):
#   def MakeLoaderAndLoad(self,
#                         problems=None,
#                         extra_validation=True,
#                         gtfs_factory=None):
#   def AppendToArchiveContents(self, arcname, s):
#   def SetArchiveContents(self, arcname, contents):
#   def GetArchiveContents(self, arcname):
#   def RemoveArchive(self, arcname):
#   def GetArchiveNames(self):
#   def CreateZip(self):
#   def DumpZipFile(self, zf):
#   def setUp(self):
#   def Load(self, feed_name):
#   def ExpectInvalidValue(self, feed_name, column_name):
#   def ExpectMissingFile(self, feed_name, file_name):
#   def setUp(self):
#   def tearDown(self):
#   def ExpectNoProblems(self, object):
#   def ValidateAndExpectMissingValue(self, object, column_name):
#   def ExpectMissingValueInClosure(self, column_name, c):
#   def ValidateAndExpectInvalidValue(self, object, column_name,
#                                     value=INVALID_VALUE):
#   def ExpectInvalidValueInClosure(self, column_name, value=INVALID_VALUE,
#                                   c=None):
#   def ValidateAndExpectInvalidFloatValue(self, object, value):
#   def ValidateAndExpectOtherProblem(self, object):
#   def ExpectOtherProblemInClosure(self, c):
#   def ValidateAndExpectDateOutsideValidRange(self, object, column_name,
#                                              value=INVALID_VALUE):
#   def ExpectException(self, type_name, column_name=None, value=INVALID_VALUE):
#   def SimpleSchedule(self):
#   def __init__(self, test_case, ignore_types=None):
#   def _Report(self, e):
#   def PopException(self, type_name):
#   def FormatException(self, exce, tb):
#   def TearDownAssertNoMoreExceptions(self):
#   def AssertNoMoreExceptions(self):
#   def PopColumnSpecificException(self, type_name, column_name, file_name=None):
#   def PopInvalidValue(self, column_name, file_name=None):
#   def PopMissingValue(self, column_name, file_name=None):
#   def PopDateOutsideValidRange(self, column_name, file_name=None):
#   def PopDuplicateColumn(self, file_name, header, count):
#   def _SortExceptionGroups(self):
#     def ProcessExceptionGroup():
#   def __init__(self, test_case, ignore_types=("ExpirationDate",)):
#   def _Report(self, e):
# def GetTestFailureProblemReporter(test_case,
#                                   ignore_types=("ExpirationDate",)):
#   def __init__(self):
#   def ExpirationDate(self, expiration, context=None):
# class TestCase(unittest.TestCase):
# class RedirectStdOutTestCaseBase(TestCase):
# class GetPathTestCase(TestCase):
# class TempDirTestCaseBase(GetPathTestCase):
# class TempFileTestCaseBase(TestCase):
# class MemoryZipTestCase(TestCase):
# class LoadTestCase(TestCase):
# class ValidationTestCase(TestCase):
# class RecordingProblemAccumulator(transitfeed.ProblemAccumulatorInterface):
# class TestFailureProblemAccumulator(transitfeed.ProblemAccumulatorInterface):
# class ExceptionProblemReporterNoExpiration(transitfeed.ProblemReporter):
#   _IGNORE_TYPES = ["ExpirationDate"]
# INVALID_VALUE = Exception()


# Path: tests/transitfeed/testschedule_write.py
from tests import util
import transitfeed

                            " ".join(r.route_id for r in route_list))
    self.assertEqual("Long Name,,,GooCar,LNR",
                     ",".join(r.route_long_name for r in route_list))

  def testTripIdConflict(self):
    problems = util.GetTestFailureProblemReporter(self)
    schedule = transitfeed.Schedule(problem_reporter=problems)
    service_period = schedule.GetDefaultServicePeriod()
    service_period.SetDateHasService("20070101")
    route = schedule.AddRoute("0", "Long Name", "Bus")
    route.AddTrip()
    route.AddTrip(schedule=schedule, headsign="hs1",
                  service_period=service_period, trip_id="1")
    route.AddTrip(schedule, "hs2", service_period, "2")
    route.AddTrip(trip_id="4")
    route.AddTrip()  # This will be given a random trip_id
    trip_list = sorted(schedule.GetTripList(), key=lambda t: int(t.trip_id))
    self.assertMatchesRegex("0 1 2 4 \d{7,9}",
                            " ".join(t.trip_id for t in trip_list))
    self.assertEqual(",hs1,hs2,,",
                     ",".join(t["trip_headsign"] for t in trip_list))
    for t in trip_list:
      self.assertEqual(service_period.service_id, t.service_id)
      self.assertEqual(route.route_id, t.route_id)


class WriteSampleFeedTestCase(util.TempFileTestCaseBase):
  def assertEqualTimeString(self, a, b):
    """Assert that a and b are equal, even if they don't have the same zero
    padding on the hour. IE 08:45:00 vs 8:45:00."""

    if a[1] == ':':