# 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: transitfeed/compat.py



import kmlparser
import os.path
import shutil
import transitfeed
import unittest
from tests import util
from transitfeed.compat import StringIO
    self.assertEqual(u'Stop Name', stop.stop_name)
    self.assertAlmostEqual(-93.239037, stop.stop_lon)
    self.assertAlmostEqual(44.854164, stop.stop_lat)
    write_output = StringIO()
    feed.WriteGoogleTransitFeed(write_output)

  def testSingleShape(self):
    feed = transitfeed.Schedule()
    kmlFile = self.GetTestDataPath('one_line.kml')
    kmlparser.KmlParser().Parse(kmlFile, feed)
    shapes = feed.GetShapeList()
    self.assertEqual(1, len(shapes))
    shape = shapes[0]
    self.assertEqual(3, len(shape.points))
    self.assertAlmostEqual(44.854240, shape.points[0][0])
    self.assertAlmostEqual(-93.238861, shape.points[0][1])
    self.assertAlmostEqual(44.853081, shape.points[1][0])
    self.assertAlmostEqual(-93.238708, shape.points[1][1])
    self.assertAlmostEqual(44.852638, shape.points[2][0])
    self.assertAlmostEqual(-93.237923, shape.points[2][1])
    write_output = StringIO()
    feed.WriteGoogleTransitFeed(write_output)


class FullTests(util.TempDirTestCaseBase):
  def testNormalRun(self):
    shutil.copyfile(self.GetTestDataPath('one_stop.kml'), 'one_stop.kml')
    (out, err) = self.CheckCallWithPath(
        [self.GetPath('kmlparser.py'), 'one_stop.kml', 'one_stop.zip'])
    # There will be lots of problems, but ignore them

# 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: transitfeed/compat.py



# Path: tests/testkmlparser.py
import kmlparser
import os.path
import shutil
import transitfeed
import unittest
from tests import util
from transitfeed.compat import StringIO

    self.assertEqual(u'Stop Name', stop.stop_name)
    self.assertAlmostEqual(-93.239037, stop.stop_lon)
    self.assertAlmostEqual(44.854164, stop.stop_lat)
    write_output = StringIO()
    feed.WriteGoogleTransitFeed(write_output)

  def testSingleShape(self):
    feed = transitfeed.Schedule()
    kmlFile = self.GetTestDataPath('one_line.kml')
    kmlparser.KmlParser().Parse(kmlFile, feed)
    shapes = feed.GetShapeList()
    self.assertEqual(1, len(shapes))
    shape = shapes[0]
    self.assertEqual(3, len(shape.points))
    self.assertAlmostEqual(44.854240, shape.points[0][0])
    self.assertAlmostEqual(-93.238861, shape.points[0][1])
    self.assertAlmostEqual(44.853081, shape.points[1][0])
    self.assertAlmostEqual(-93.238708, shape.points[1][1])
    self.assertAlmostEqual(44.852638, shape.points[2][0])
    self.assertAlmostEqual(-93.237923, shape.points[2][1])
    write_output = StringIO()
    feed.WriteGoogleTransitFeed(write_output)


class FullTests(util.TempDirTestCaseBase):
  def testNormalRun(self):
    shutil.copyfile(self.GetTestDataPath('one_stop.kml'), 'one_stop.kml')
    (out, err) = self.CheckCallWithPath(
        [self.GetPath('kmlparser.py'), 'one_stop.kml', 'one_stop.zip'])
    # There will be lots of problems, but ignore them

    accumulator = util.RecordingProblemAccumulator(self)