Skip to content

Modify get params to use api_key defined in params#85

Open
harshulsahni wants to merge 5 commits intoceliao:masterfrom
harshulsahni:modify_get_params
Open

Modify get params to use api_key defined in params#85
harshulsahni wants to merge 5 commits intoceliao:masterfrom
harshulsahni:modify_get_params

Conversation

@harshulsahni
Copy link

the _get_params function only relied on tmdb.API_KEY = ... to set an API key. This PR aims to add functionality so that the user can specify an API key in every function to eliminate this global dependency.

See the test test_tmdb_get_params_no_api_with_search in test_base.py for example usage.

Also, this PR simplifies some boolean and string logic to for conciseness.

tmdb.API_KEY = None
with self.assertRaises(tmdb.base.APIKeyError):
tmdb_no_api_defined._get_params(params={})
tmdb.API_KEY = API_KEY
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everytime I change the API_KEY to None, I "reset" it like so to preserve the other tests

@celiao
Copy link
Owner

celiao commented Jan 25, 2022

@harshulsahni Why do you want to use more than one API Key?

@harshulsahni
Copy link
Author

@celiao I don't want to use more than one API key, but rather I would like the endpoint functions (e.g. search.movie()) to be used without having to define the API key at the top of some file. It would be much cleaner (in my opinion) to have the API key defined in the arguments of these functions so they can be more modular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants