Skip to content

Commit

Permalink
query parameters are removed in POST mode, tests|
Browse files Browse the repository at this point in the history
  • Loading branch information
davidesner committed Aug 13, 2024
1 parent 7c9f1fd commit b29e12b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python-sync-actions/src/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@ def build_api_request(configuration: dict) -> List[Tuple[ApiRequest, RequestCont
delimiter = "."
data_path = DataPath(path=path, delimiter=delimiter)

# query params are supported only for GET requests
if request_content.content_type == ContentType.none:
query_params = endpoint_config.get('params', {})
else:
query_params = {}

result_requests.append(
(ApiRequest(method=method,
endpoint_path=endpoint_path,
placeholders=placeholders,
headers=endpoint_config.get('headers', {}),
query_parameters=endpoint_config.get('params', {}),
query_parameters=query_params,
scroller=scroller),
request_content,
data_path))
Expand Down
55 changes: 55 additions & 0 deletions python-sync-actions/tests/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import configuration
from configuration import ConfigHelpers


Expand Down Expand Up @@ -57,3 +58,57 @@ def test_eval_source_function_true(self):
'params': {'grant_type': 'client_credentials', 'scope': 'read'}}
result = self.helpers.fill_in_user_parameters(conf_objects, user_params, True)
self.assertEqual(result, expected)

def test_query_parameters_dropped_in_post_mode(self):
config = {
"__SELECTED_JOB": "0",
"config": {
"userData": {},
"outputBucket": "",
"incrementalOutput": False,
"jobs": [
{
"__NAME": "63aa2677-41d6-49d9-8add-2ccc18e8062e",
"endpoint": "v3/63aa2677-41d6-49d9-8add-2ccc18e8062e",
"method": "POST",
"dataType": "63aa2677-41d6-49d9-8add-2ccc18e8062e",
"params": {
"test": "test"
}
}
]
},
"api": {
"baseUrl": "https://run.mocky.io/"
}
}

configs = configuration.convert_to_v2(config)
self.assertEqual(configs[0].request_parameters.query_parameters, {})

def test_query_parameters_kept_in_get_mode(self):
config = {
"__SELECTED_JOB": "0",
"config": {
"userData": {},
"outputBucket": "",
"incrementalOutput": False,
"jobs": [
{
"__NAME": "63aa2677-41d6-49d9-8add-2ccc18e8062e",
"endpoint": "v3/63aa2677-41d6-49d9-8add-2ccc18e8062e",
"method": "GET",
"dataType": "63aa2677-41d6-49d9-8add-2ccc18e8062e",
"params": {
"test": "testValue"
}
}
]
},
"api": {
"baseUrl": "https://run.mocky.io/"
}
}

configs = configuration.convert_to_v2(config)
self.assertDictEqual(configs[0].request_parameters.query_parameters, {"test": "testValue"})

0 comments on commit b29e12b

Please sign in to comment.