Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove app_id from tfl api token as it's not needed any more #47

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions pydantic_tfl_api/api_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ class ApiToken():
:param str app_key: Application Key from the API credentails
"""

def __init__(self, app_id, app_key):
self.app_id = app_id
def __init__(self, app_key):
self.app_key = app_key
2 changes: 1 addition & 1 deletion pydantic_tfl_api/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RestClient():
"""

def __init__(self, api_token: ApiToken = None):
self.api_token = {"app_id": api_token.app_id, "app_key": api_token.app_key} if api_token else None
self.api_token = {"app_key": api_token.app_key} if api_token else None

def send_request(self, location, params=None):
return requests.get(base_url + location + "?" + self._get_query_strings(params))
Expand Down
13 changes: 6 additions & 7 deletions tests/test_basic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
# to make sure that the pydantic models load
# and that the TFL API connectivity is ok - although we'll have
def test_create_api_token():
api_token = ApiToken('your_api_token', 'app_key')
assert api_token.app_id == 'your_api_token'
assert api_token.app_key == 'app_key'
api_token = ApiToken('your_app_key')
assert api_token.app_key == 'your_app_key'

def test_create_client_with_api_token():
# checks that the API key is being passed to the RestClient
api_token = ApiToken('your_api_token', 'app_key')
api_token = ApiToken('your_app_key')
client = Client(api_token)
assert client.client.api_token['app_id'] == 'your_api_token'
assert client.client.api_token['app_key'] == 'your_app_key'

def test_get_line_status_by_mode_rejected_with_invalid_api_key():
api_token = ApiToken('your_api_token', 'app_key')
api_token = ApiToken('your_app_key')
client = Client(api_token)
assert client.client.api_token['app_id'] == 'your_api_token'
assert client.client.api_token['app_key'] == 'your_app_key'
# should get a 429 error inside an ApiError object
result = client.get_line_status_by_mode('overground,tube')
assert isinstance(result, ApiError)
Expand Down
Loading