Example #1
0
def reply_to_sms_message(request):
    text = request.REQUEST['Body']
    mtd = CumtdApi(os.environ['CUMTD_API_KEY'])
    stops = mtd.get_stops_by_search(text)
    buses = mtd.get_departures_by_stop(stops['stops'][0]['stop_id'])
    r = Response()
    response_text = 'Departures at ' + stops['stops'][0]['stop_name'] + '\n'
    for trip in buses['departures']:
        response_text += trip['headsign'] + ' in ' + str(trip['expected_mins']) + ' mins\n'
    r.sms(response_text[:159])
    return r
Example #2
0
"""
Non-exhaustive tests for the CUMTD API Python helper library. Currently only tests baseline positive cases and does not test for specific output.
"""

from cumtd import CumtdApi
from datetime import datetime

KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

mtd = CumtdApi(KEY, debug=True)

now = datetime.now()

print "Testing GetCalendarDatesByDate"
services = mtd.get_calendar_dates_by_date(now.strftime('%Y-%m-%d'))
print services

print "Testing GetCalendarDatesByService"
print mtd.get_calendar_dates_by_service(services['calendar_dates'][0]['service_id'])

print "Testing GetDeparturesByStop"
print mtd.get_departures_by_stop('GRNWRT')

print "Testing GetRoute"
print mtd.get_route('GREEN')

print "Testing GetRoutes"
print mtd.get_routes()

print "Testing GetShape"
print mtd.get_shape('5E')