diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-28 01:24:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 01:24:13 +0200 |
commit | 510ec30f30e7ff8466b58d2661b67076de9d234b (patch) | |
tree | da3116aa356818cb2a865b047de9ef160bbfffa7 /tests/unit/test_utils.py | |
parent | 194ee0100c2868c1a9afb161c15f3145efb01c7c (diff) | |
parent | 1af44ce8761e6ee8a9467a3e192f6c4d19e5cefe (diff) | |
download | gitlab-510ec30f30e7ff8466b58d2661b67076de9d234b.tar.gz |
Merge pull request #1699 from python-gitlab/jlvillal/arrays
fix: use the [] after key names for array variables in `params`
Diffstat (limited to 'tests/unit/test_utils.py')
-rw-r--r-- | tests/unit/test_utils.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index ce2e776..6038d84 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -155,7 +155,7 @@ def test_remove_none_from_dict(dictionary, expected): def test_transform_types_copies_data_with_empty_files(): data = {"attr": "spam"} - new_data, files = utils._transform_types(data, {}) + new_data, files = utils._transform_types(data, {}, transform_data=True) assert new_data is not data assert new_data == data @@ -165,7 +165,7 @@ def test_transform_types_copies_data_with_empty_files(): def test_transform_types_with_transform_files_populates_files(): custom_types = {"attr": types.FileAttribute} data = {"attr": "spam"} - new_data, files = utils._transform_types(data, custom_types) + new_data, files = utils._transform_types(data, custom_types, transform_data=True) assert new_data == {} assert files["attr"] == ("attr", "spam") @@ -174,7 +174,29 @@ def test_transform_types_with_transform_files_populates_files(): def test_transform_types_without_transform_files_populates_data_with_empty_files(): custom_types = {"attr": types.FileAttribute} data = {"attr": "spam"} - new_data, files = utils._transform_types(data, custom_types, transform_files=False) + new_data, files = utils._transform_types( + data, custom_types, transform_files=False, transform_data=True + ) assert new_data == {"attr": "spam"} assert files == {} + + +def test_transform_types_params_array(): + data = {"attr": [1, 2, 3]} + custom_types = {"attr": types.ArrayAttribute} + new_data, files = utils._transform_types(data, custom_types, transform_data=True) + + assert new_data is not data + assert new_data == {"attr[]": [1, 2, 3]} + assert files == {} + + +def test_transform_types_not_params_array(): + data = {"attr": [1, 2, 3]} + custom_types = {"attr": types.ArrayAttribute} + new_data, files = utils._transform_types(data, custom_types, transform_data=False) + + assert new_data is not data + assert new_data == data + assert files == {} |