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 ): # will raise NoMockAddress exception if obj1 != request.json() HttpHook(method=method).run('v1/test', json=obj1) ``` here i am also suggesting removing those asserts. they are just checking that your mock is returning what you told it to return -- the fact that no exception is raised in `hook.run` is the actual indicator that the test was passed. the asserts don't test anything beyond that. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services