Skip to content

Commit aa9b031

Browse files
author
Kees Hink
authored
Merge pull request #387 from mollie/386-testmode-without-data
Check if data exists, otherwise make it a dict
2 parents c76d738 + 02c3da4 commit aa9b031

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
# urllib3, https://data.safetycli.com/v/77744/97c, only when using python 3.8. Consider upgrading.
3838
# setuptools, https://data.safetycli.com/v/76752/97c, only when using python 3.8. Consider upgrading.
3939
# regex, https://data.safetycli.com/v/78558/97c, only when using python 3.8. Consider upgrading.
40-
run: python -m safety check --ignore 70612 --ignore 77744 --ignore 77745 --ignore 76752 --ignore 78558
40+
# pip, https://data.safetycli.com/v/79883/97c, only when using python 3.8. Consider upgrading.
41+
# authlib, https://data.safetycli.com/v/79756/97c, only when using python 3.8. Consider upgrading.
42+
run: python -m safety check --ignore 70612 --ignore 77744 --ignore 77745 --ignore 76752 --ignore 78558 --ignore 79883 --ignore 79756
4143

4244
- name: Verify code style
4345
run: python -m flake8 -v

mollie/api/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ def _get_testmode(self, data, params, http_method):
201201
if http_method == "GET":
202202
params["testmode"] = params.get("testmode") or "true"
203203
elif not data or "testmode" not in data:
204+
if not data:
205+
data = {}
206+
204207
data["testmode"] = params.get("testmode") or True
205208

206209
# Delete from the params since it's not a valid parameter when the request is not GET

tests/test_api_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,9 @@ def test__get_testmode_sets_data_or_params_correctly(oauth_client, testmode, par
600600
oauth_client.testmode = testmode
601601
return_value = oauth_client._get_testmode({}, params, http_method)
602602
assert return_value == expected
603+
604+
605+
def test__get_testmode_does_not_crash_when_no_data(oauth_client):
606+
oauth_client.testmode = True
607+
return_value = oauth_client._get_testmode(None, {}, "POST")
608+
assert return_value == ({"testmode": True}, {})

0 commit comments

Comments
 (0)