Exemple #1
0
class RouteListMockTestCase(TestCase):
  def mockRouteXml(self):
    return """
    <body>
      <route tag="1" title="1 - California" shortTitle="1-Calif"/>
      <route tag="3" title="3 - Jackson" shortTitle="3-Jacksn"/>
      <route tag="4" title="4 - Sutter" shortTitle="4-Sutter"/>
      <route tag="5" title="5 - Fulton" shortTitle="5-Fulton"/>
      <route tag="6" title="6 - Parnassus" shortTitle="6-Parnas"/>
      <route tag="7" title="7 - Haight" shortTitle="7-Haight"/>
      <route tag="14" title="14 - Mission" shortTitle="14-Missn"/>
      <route tag="21" title="21 - Hayes" shortTitle="21-Hayes"/>
    </body>
    """

  def setUp(self):
    self.route_list = RouteList(agency='sf-muni')
    self.route_list._fetch_raw_xml = self.mockRouteXml
    self.route_list.fetch()

  def testXmlParsing(self):
    routes = self.route_list['routes']

    self.assertEqual(len(routes), 8)
    self.assertIn("21", [route['tag'] for route in routes])
    self.assertIn("21 - Hayes", [route['title'] for route in routes])
Exemple #2
0
def route_list(request):
  return HttpResponse(RouteList.get(agency='sf-muni'))
Exemple #3
0
 def setUp(self):
   self.route_list = RouteList.get(agency='sf-muni')
Exemple #4
0
 def setUp(self):
   self.route_list = RouteList(agency='sf-muni')
   self.route_list._fetch_raw_xml = self.mockRouteXml
   self.route_list.fetch()