dstandish commented on a change in pull request #6886: [AIRFLOW-6327]
http_hook: Accept json= parameter for payload
URL: https://github.com/apache/airflow/pull/6886#discussion_r362168727
##########
File path: tests/hooks/test_http_hook.py
##########
@@ -334,5 +334,42 @@ def test_connection_without_host(self,
mock_get_connection):
hook.get_conn({})
self.assertEqual(hook.base_url, 'http://')
+ @requests_mock.mock()
Review comment:
this is may be super nit picky, but you could simplify using parameters if
you want to
```suggestion
@parameterized.expand([
'GET',
'POST',
])
@requests_mock.mock()
def test_json_request(self, method, mock_requests):
obj1 = {'a': 1, 'b': 'abc', 'c': [1, 2, {"d": 10}]}
def match_obj1(request):
return request.json() == obj1
mock_requests.request(
method=method,
url='//test:8080/v1/test',
additional_matcher=match_obj1
)
with mock.patch(
'airflow.hooks.base_hook.BaseHook.get_connection',
side_effect=get_airflow_connection
):
# Send obj1 as JSON and verify it matched the mock
HttpHook(method=method).run('v1/test', json=obj1)
```
apart from the parameterization, in my suggestion i chop a few things i'll
make some inline comments to explain
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services