Repository navigation
Fix testmode when following pagination and _links URLs - #398
Open
ratomirjovanovic wants to merge 1 commit into
Open
ratomirjovanovic wants to merge 1 commit into
ratomirjovanovic wants to merge 1 commit into
Conversation
_get_testmode assumed params was a dict, so with testmode enabled every request made without params (PaginationList.get_next/get_previous and from_url) failed with an AttributeError. Links from the API also already carry a querystring, so append extra params with "&" and skip the ones the link already has.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
set_testmode(True)on an OAuth or access token client, any GET made without params fails in_get_testmode, becauseparamsisNonethere and the code doesparams["testmode"] = params.get(...):PaginationList.get_next()/get_previous()andResourceBase.from_url()all callperform_api_callwithout params, so in testmode you can't go past the first page of a list or follow a link likepayment.customer. #390 was the same crash fordata=None, fixed in #387; this is theparamsside.Fixing only that isn't enough: those URLs already have a querystring (
.../customers?from=cst_...&limit=5), and_format_request_dataappends the extra params with another?, so the request would go to...&limit=5?testmode=true. This change:params=Noneas{}in_get_testmode&, and skips params the URL already containsTests: added the
Noneparams cases totest__get_testmode_sets_data_or_params_correctly, a test that pages through customers in testmode and checks the second request is?from=cst_8pknKQJzJa&limit=5&testmode=true, and a test that a param already in the URL isn't added twice. All of them fail onmainand pass with this change.Ran
pytest(285 passed),flake8andmypy --config mypy.ini mollie/locally.