kaxil commented on pull request #5519:
URL: https://github.com/apache/airflow/pull/5519#issuecomment-622995610


   The following diff should also check and fix the issue:
   
   ```diff
   diff --git a/airflow/providers/slack/hooks/slack.py 
b/airflow/providers/slack/hooks/slack.py
   index 3a0cd693c..d4d558e7a 100644
   --- a/airflow/providers/slack/hooks/slack.py
   +++ b/airflow/providers/slack/hooks/slack.py
   @@ -80,7 +80,7 @@ class SlackHook(BaseHook):
            :param api_params: parameters of the API
            """
            slack_client = WebClient(self.token, **self.client_args)
   -        return_code = slack_client.api_call(method, **api_params)
   +        return_code = slack_client.api_call(method, json=api_params)
   
            try:
                return_code.validate()
   diff --git a/tests/providers/slack/hooks/test_slack.py 
b/tests/providers/slack/hooks/test_slack.py
   index 1594d8b1d..cfb5c79dc 100644
   --- a/tests/providers/slack/hooks/test_slack.py
   +++ b/tests/providers/slack/hooks/test_slack.py
   @@ -160,3 +160,13 @@ class TestSlackHook(unittest.TestCase):
            except AirflowException as exc:
                self.assertIn("foo", str(exc))
                self.assertIn("bar", str(exc))
   +
   +    @mock.patch('airflow.providers.slack.hooks.slack.WebClient.api_call', 
autospec=True)
   +    @mock.patch('airflow.providers.slack.hooks.slack.WebClient')
   +    def test_api_call(self, mock_slack_client, mock_slack_api_call):
   +        slack_hook = SlackHook(token='test_token')
   +        test_api_params = {'channel': 'd'}
   +
   +        slack_hook.call("chat.postMessage", test_api_params)
   +        mock_slack_api_call.assert_called_once_with(
   +            mock_slack_client, "chat.postMessage", json=test_api_params)
   ```


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