Skip to content

Commit

Permalink
[AIRFLOW-4857] Add templated fields to SlackWebhookOperator (apache#5490
Browse files Browse the repository at this point in the history
)

(cherry picked from commit 8b7f93d)
  • Loading branch information
kaxil committed Jun 27, 2019
1 parent 0660820 commit 3355ad9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions airflow/contrib/operators/slack_webhook_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class SlackWebhookOperator(SimpleHttpOperator):
:type proxy: str
"""

template_fields = ['webhook_token', 'message', 'attachments', 'channel',
'username', 'proxy', ]

@apply_defaults
def __init__(self,
http_conn_id=None,
Expand Down
11 changes: 11 additions & 0 deletions tests/contrib/operators/test_slack_webhook_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ def test_execute(self):
self.assertEqual(self._config['link_names'], operator.link_names)
self.assertEqual(self._config['proxy'], operator.proxy)

def test_assert_templated_fields(self):
operator = SlackWebhookOperator(
task_id='slack_webhook_job',
dag=self.dag,
**self._config
)

template_fields = ['webhook_token', 'message', 'attachments', 'channel', 'username', 'proxy']

self.assertEqual(operator.template_fields, template_fields)


if __name__ == '__main__':
unittest.main()

0 comments on commit 3355ad9

Please sign in to comment.