Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nextbus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def route_config(agency=None, route=None, **kwargs):

def predictions(agency=None, route=None, stop_id=None, **kwargs):
"""prediction"""
result = __api_call('predictions', agency=agency, route=route, stop_id=stop_id, **kwargs) or []
result = __api_call('predictions', agency=agency, route=route, stopId=stop_id, **kwargs) or []
return result

def set_defaults(defaults):
Expand Down
7 changes: 7 additions & 0 deletions nextbus/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from lxml import etree


class UnknownCommandError(Exception):
pass


def parse_command(command, xml):
"""parses the xml document based on the command used. returns the object structure
associated with that xml"""
Expand All @@ -10,6 +15,8 @@ def parse_command(command, xml):
result = __parse_routeList(xml)
elif command == 'routeConfig':
result = __parse_routeConfig(xml)
else:
raise UnknownCommandError("Command {0} is not recognized or not implemented".format(command))

return result

Expand Down
37 changes: 25 additions & 12 deletions nextbus/test_nextbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@

import unittest

def test_agencyList():
#agency list should always return a list of agencies
agencies = nextbus.agency_list()
assert len(agencies) > 0 and type(agencies[0]) == Agency
class AgencyListTest(unittest.TestCase):
def test_agencyList(self):
#agency list should always return a list of agencies
agencies = nextbus.agency_list()
self.assertTrue(len(agencies) > 0, "Agencies list should not be empty")
self.assertTrue(isinstance(agencies[0], Agency), "agency_list not returning a list of Agencies")
# if willing to break 2.6, can use assertIsInstance instead

def test_routeList():
#route list should always return a list of routes filtered by agency.
routes = nextbus.route_list(agency='sf-muni')
assert len(routes) > 0 and type(routes[0]) == Route and routes[0].title == 'F-Market & Wharves'
def test_routeList(self):
#route list should always return a list of routes filtered by agency.
routes = nextbus.route_list(agency='sf-muni')
self.assertTrue(len(routes) > 0,
"Routes list should not be empty")
self.assertTrue(isinstance(routes[0], Route),
"route_list not returning a list of Routes")
self.assertTrue("F-Market & Wharves" in [route.title for route in routes],
"A route is missing from the route list")
self.assertFalse("Sandwich" in [route.title for route in routes],
"route_list is including multiple agencies")

def test_routeConfig():
#route config should return a route object by the given route tag
route = nextbus.route_config(agency='sf-muni', route='1')
assert route and type(route) == Route and route.title == '1-California'
def test_routeConfig(self):
#route config should return a route object by the given route tag
route = nextbus.route_config(agency='sf-muni', route='1')
self.assertTrue(route, "Route is empty")
self.assertTrue(isinstance(route, Route), "route_config is not returning a Route")
self.assertEqual(route.title, "1-California",
"Route title is not right (expected '{0}', got '{1}'".format("1-California", route.title))


4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.0.1
lxml==3.2.4
requests>=2.0.1
lxml>=3.2.4
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
import sys

import nextbus

try:
from setuptools import setup
except ImportError:
Expand All @@ -18,19 +16,19 @@
'nextbus',
]

requires = []
requires = ['requests>=2.0.1', 'lxml>=3.2.4']

readme =''
history =''

setup(
name='python-nextbus',
version=nextbus.__version__,
version='0.1b',
description='python client for nextbus api',
long_description=readme + '\n\n' + history,
author='Sam Bolgert',
author_email='sbolgert@gmail.com',
url='http://python.org',
url='https://github.com/linuxlewis/python-nextbus',
packages=packages,
package_data={'': ['LICENSE', 'NOTICE']},
package_dir={'nextbus': 'nextbus'},
Expand All @@ -39,14 +37,14 @@
license=license,
zip_safe=False,
classifiers=(
'Development Status :: 3 - Alpha',
'Development Status :: 6 - Mature',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',

'Programming Language :: Python :: 3.5'
),
)
)