pgagnon commented on a change in pull request #16512:
URL: https://github.com/apache/airflow/pull/16512#discussion_r653938595



##########
File path: tests/providers/apache/livy/hooks/test_livy.py
##########
@@ -316,6 +316,20 @@ def test_invalid_uri(self):
         with pytest.raises(RequestException):
             hook.post_batch(file='sparkapp')
 
+    @requests_mock.mock()
+    def test_extra_headers(self, mock):
+        mock.register_uri(
+            'POST',
+            '//livy:8998/batches',
+            json={'id': BATCH_ID, 'state': BatchState.STARTING.value, 'log': 
[]},
+            status_code=201,
+            request_headers={'X-Requested-By': 'user'}
+        )
+
+        hook = LivyHook(extra_headers={'X-Requested-By': 'user'})
+        hook.post_batch(file='sparkapp')
+

Review comment:
       It checks that `X-Requested-By: user` is present in the request headers.

##########
File path: tests/providers/apache/livy/hooks/test_livy.py
##########
@@ -316,6 +316,20 @@ def test_invalid_uri(self):
         with pytest.raises(RequestException):
             hook.post_batch(file='sparkapp')
 
+    @requests_mock.mock()
+    def test_extra_headers(self, mock):
+        mock.register_uri(
+            'POST',
+            '//livy:8998/batches',
+            json={'id': BATCH_ID, 'state': BatchState.STARTING.value, 'log': 
[]},
+            status_code=201,
+            request_headers={'X-Requested-By': 'user'}
+        )
+
+        hook = LivyHook(extra_headers={'X-Requested-By': 'user'})
+        hook.post_batch(file='sparkapp')
+

Review comment:
       It checks that `X-Requested-By: user` is present in the request headers.
   
   edit: ref: 
https://requests-mock.readthedocs.io/en/latest/matching.html#request-headers

##########
File path: tests/providers/apache/livy/hooks/test_livy.py
##########
@@ -255,7 +255,7 @@ def test_post_batch_arguments(self, mock_request):
         resp = hook.post_batch(file='sparkapp')
 
         mock_request.assert_called_once_with(
-            method='POST', endpoint='/batches', data=json.dumps({'file': 
'sparkapp'})
+            method='POST', endpoint='/batches', data=json.dumps({'file': 
'sparkapp'}), headers={}

Review comment:
       @kaxil I modified this test slightly. Just wanted to explicitely point 
it out.

##########
File path: tests/providers/apache/livy/hooks/test_livy.py
##########
@@ -255,7 +255,7 @@ def test_post_batch_arguments(self, mock_request):
         resp = hook.post_batch(file='sparkapp')
 
         mock_request.assert_called_once_with(
-            method='POST', endpoint='/batches', data=json.dumps({'file': 
'sparkapp'})
+            method='POST', endpoint='/batches', data=json.dumps({'file': 
'sparkapp'}), headers={}

Review comment:
       @kaxil I modified this test slightly. Just wanted to explicitly point it 
out.




-- 
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]


Reply via email to