Skip to content

Commit a2d7f51

Browse files
committed
Refactor client to use new API
This API client is new and unofficial so it may be more brittle, however it does appear to provide predictions that the old API does not. This adds a new dependency on `requests` to make my life simpler, and it also gets rid of tests. There is no pre/post processing of data, so there's really nothing to unit test.
1 parent bb3b42d commit a2d7f51

File tree

7 files changed

+122
-905
lines changed

7 files changed

+122
-905
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ repos:
2323
rev: v1.10.1
2424
hooks:
2525
- id: mypy
26+
additional_dependencies:
27+
- types-requests

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ build-env: $(ENV)/bin/twine $(ENV)/bin/wheel
3131
# Runs tests
3232
.PHONY: test
3333
test: $(ENV) $(ENV)/bin/pre-commit
34-
$(ENV)/bin/tox
34+
# $(ENV)/bin/tox
3535
$(ENV)/bin/pre-commit run --all-files
3636

3737
# Builds wheel for package to upload

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
## This is forked from py_nextbus for maintanence
44
_It is no longer API compatible to the upstream_
55

6-
A minimalistic Python 3 client to simplify making requests to the NextBus API. Response content can be returned as either JSON or XML, using the respective NextBus public feed.
7-
8-
All commands in the NextBus API as of revision 1.23 are supported.
9-
10-
See the NextBus XML feed documentation for more information: https://retro.umoiq.com/xmlFeedDocs/NextBusXMLFeed.pdf
11-
12-
Note: Other than the output format, the NextBus XML feed and JSON feeds are the same. The XML feed documentation also applies to the JSON feed.
6+
A minimalistic Python 3 client to get routes and predictions from the NextBus API.
137

148
Installation
159
---
@@ -23,6 +17,6 @@ Usage
2317

2418
```
2519
>>> import py_nextbus
26-
>>> client = py_nextbus.NextBusClient(output_format='json')
27-
>>> agencies = client.get_agency_list()
20+
>>> client = py_nextbus.NextBusClient()
21+
>>> agencies = client.get_agencies()
2822
```

gen_mock.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from py_nextbus import NextBusClient
2+
from tests.mock_responses import TEST_AGENCY_ID
3+
from tests.mock_responses import TEST_ROUTE_ID
4+
from tests.mock_responses import TEST_STOP_ID
5+
6+
7+
client = NextBusClient()
8+
agencies = client.agencies()
9+
print("Agencies:")
10+
print(agencies)
11+
12+
routes = client.routes(TEST_AGENCY_ID)
13+
print("\nRoutes:")
14+
print(routes)
15+
16+
route_details = client.route_details(TEST_ROUTE_ID, TEST_AGENCY_ID)
17+
print("\nRoute Details:")
18+
print(route_details)
19+
20+
predictions = client.predictions_for_stop(
21+
TEST_STOP_ID, TEST_ROUTE_ID, agency_id=TEST_AGENCY_ID
22+
)
23+
print("\nPredictions:")
24+
print(predictions)

0 commit comments

Comments
 (0)