-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes "filter" Parameter in methods GET
- Loading branch information
1 parent
a3e9242
commit 8295b38
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from src.tagoio_sdk.common.tagoio_module import TagoIOModule | ||
|
||
|
||
def test_converter_dict_param_filter_single_key_value(): | ||
""" | ||
Test case 1: dictionary with single key-value pair | ||
""" | ||
params = {"filter": {"tags": [{"key": "org_id", "value": "123"}]}} | ||
expected_result = {"filter[tags][0][key]": "org_id", "filter[tags][0][value]": "123"} | ||
|
||
tokenFake = {"token": "fake_token"} | ||
TagoIOModule(params=tokenFake)._converter_dict_param_filter(params) == expected_result | ||
|
||
assert params == expected_result | ||
|
||
|
||
def test_converter_dict_param_filter_multiple_key_value(): | ||
""" | ||
Test case 2: dictionary with multiple key-value pairs | ||
""" | ||
params = { | ||
"filter": { | ||
"tags": [ | ||
{"key": "org_id", "value": "123"}, | ||
{"key": "device_type", "value": "test"} | ||
] | ||
} | ||
} | ||
expected_result = { | ||
"filter[tags][0][key]": "org_id", | ||
"filter[tags][0][value]": "123", | ||
"filter[tags][1][key]": "device_type", | ||
"filter[tags][1][value]": "test" | ||
} | ||
|
||
tokenFake = {"token": "fake_token"} | ||
TagoIOModule(params=tokenFake)._converter_dict_param_filter(params) == expected_result | ||
|
||
assert params == expected_result |