bryanyang0528 commented on a change in pull request #5004: [AIRFLOW-4187]
SlackWebhookOperator do not pass http_conn_id to its parent class
URL: https://github.com/apache/airflow/pull/5004#discussion_r270492480
##########
File path: tests/contrib/hooks/test_slack_webhook_hook.py
##########
@@ -91,6 +92,16 @@ def test_build_slack_message(self):
# Then
self.assertEqual(self.expected_message, message)
+ def test_get_base_url_default(self):
+ hook = SlackWebhookHook(http_conn_id='http_default')
+ hook.get_conn()
+
+ self.assertEqual(hook._get_base_url(), 'https://www.google.com/')
Review comment:
According to this
article:https://stackoverflow.com/questions/52054427/how-to-integrate-apache-airflow-with-slack/52054663
SlackWebhookOperator could be set like this:
```
from airflow.contrib.operators.slack_webhook_operator import
SlackWebhookOperator
slack_msg="Hi Wssup?"
slack_test = SlackWebhookOperator(
task_id='slack_test',
http_conn_id='slack_connection',
webhook_token='/1234/abcd',
message=slack_msg,
channel='#airflow_updates',
username='airflow_'+os.environ['ENVIRONMENT'],
icon_emoji=None,
link_names=False,
dag=dag)
```
And set the host of slack in connection like this:
`host=https://hooks.slack.com/services/`
The argument-`http_conn_id` will be used for getting the hostname of Slack.
But in current version, `http_conn_id` can't be passed the parent
class-`HTTPHOOK`, so that `HTTPHook` will read the host by the default
http_conn_id `http_default` and send the msg to
`https://www.google.com/YOUR_ENDPOINT`.
----------------------------------------------------------------
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