def test_point(self): agency = util.preload_agency() point = agency.point() expect = [-116.76705100000001, 36.670485] for i, j in zip(point, expect): self.assertAlmostEqual(i, j) self.assertAlmostEqual(point[0], expect[0]) self.assertAlmostEqual(point[1], expect[1])
def test_point(self): agency = util.preload_agency() point = agency.point() expect = [-116.76705100000001, 36.670485] for i,j in zip(point, expect): self.assertAlmostEqual(i,j) self.assertAlmostEqual(point[0], expect[0]) self.assertAlmostEqual(point[1], expect[1])
def test_stop_sequence(self): agency = util.preload_agency() entity = agency.trip(self.expect['trip_id']) stop_sequence = entity.stop_sequence() assert len(stop_sequence) == 5 expect = ['1', '2', '3', '4', '5'] for i,j in zip(stop_sequence, expect): assert i.get('stop_sequence') == j
def test_json(self): agency = util.preload_agency() entity = agency.route(self.expect['route_id']) data = entity.json() assert data['name'] == entity.name() assert data['type'] == 'Feature' assert data['geometry']['type'] == 'MultiLineString' # Round trip assert json.loads(json.dumps(data))
def test_json(self): # Basic checks for JSON sanity. agency = util.preload_agency() data = agency.json() assert data['name'] == 'Demo Transit Authority' assert 'geometry' in data assert 'bbox' in data assert len(data['features']) == 9 # Round trip assert json.loads(json.dumps(data))
def test_geometry(self): agency = util.preload_agency() geometry = agency.geometry() # a beast... expect = [(-117.133162, 36.425288), (-116.40094, 36.641496), (-116.751677, 36.915682), (-116.76821, 36.914893), (-116.81797, 36.88108), (-117.133162, 36.425288)] assert geometry['type'] == 'Polygon' for i, j in zip(geometry['coordinates'][0], expect): self.assertAlmostEqual(i[0], j[0]) self.assertAlmostEqual(i[1], j[1])
def test_geometry(self): agency = util.preload_agency() geometry = agency.geometry() # a beast... expect = [ (-117.133162, 36.425288), (-116.40094, 36.641496), (-116.751677, 36.915682), (-116.76821, 36.914893), (-116.81797, 36.88108), (-117.133162, 36.425288) ] assert geometry['type'] == 'Polygon' for i,j in zip(geometry['coordinates'][0], expect): self.assertAlmostEqual(i[0],j[0]) self.assertAlmostEqual(i[1],j[1])
def test_geometry(self): agency = util.preload_agency() route = agency.route(self.expect['route_id']) geometry = route.geometry() assert geometry['type'] == 'MultiLineString' # Line 1 expect = [ (-116.784582, 36.868446), (-116.81797, 36.88108)] for i,j in zip(geometry['coordinates'][0], expect): self.assertAlmostEqual(i[0],j[0]) self.assertAlmostEqual(i[1],j[1]) # Line 2 expect = [ (-116.81797, 36.88108), (-116.784582, 36.868446) ] for i,j in zip(geometry['coordinates'][1], expect): self.assertAlmostEqual(i[0],j[0]) self.assertAlmostEqual(i[1],j[1])
def test_routes(self): agency = util.preload_agency() entity = agency.stop(self.expect['stop_id']) routes = entity.routes() assert len(routes) == 1 assert list(routes)[0].id() == 'BFC'
def test_stop_times(self): agency = util.preload_agency() assert len(agency.stop_times()) == 28
def test_stop(self): agency = util.preload_agency() assert agency.stop('NANAA')
def test_trip(self): agency = util.preload_agency() assert agency.trip('AB1')
def test_trips(self): agency = util.preload_agency() assert len(agency.trips()) == 11
def test_bbox(self): agency = util.preload_agency() route = agency.route(self.expect['route_id']) expect = [-116.81797, 36.868446, -116.784582, 36.88108] for i,j in zip(route.bbox(), expect): self.assertAlmostEqual(i,j)
def test_bbox(self): agency = util.preload_agency() expect = [-117.133162, 36.425288, -116.40094, 36.915682] for i,j in zip(agency.bbox(), expect): self.assertAlmostEqual(i,j)
def test_routes(self): agency = util.preload_agency() assert len(agency.routes()) == 5
def test_stop_times(self): agency = util.preload_agency() entity = agency.trip(self.expect['trip_id']) assert len(entity.stop_times()) == 5
def test_bbox(self): agency = util.preload_agency() expect = [-117.133162, 36.425288, -116.40094, 36.915682] for i, j in zip(agency.bbox(), expect): self.assertAlmostEqual(i, j)
def test_route(self): agency = util.preload_agency() assert agency.route('AB')
def test_stops(self): agency = util.preload_agency() route = agency.route(self.expect['route_id']) assert len(route.stops()) == 2