コード例 #1
0
 def test_build_feed_card_message(self):
     msg = {
         "links": [{
             "title": "Airflow DAG feed card",
             "messageURL":
             "https://airflow.readthedocs.io/en/latest/ui.html",
             "picURL": "http://airflow.apache.org/_images/dags.png"
         }, {
             "title": "Airflow tree feed card",
             "messageURL":
             "https://airflow.readthedocs.io/en/latest/ui.html",
             "picURL": "http://airflow.apache.org/_images/tree.png"
         }, {
             "title": "Airflow graph feed card",
             "messageURL":
             "https://airflow.readthedocs.io/en/latest/ui.html",
             "picURL": "http://airflow.apache.org/_images/graph.png"
         }]
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'feedCard',
         'message': msg
     }
     expect = {'msgtype': 'feedCard', 'feedCard': msg}
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #2
0
 def test_build_single_action_card_message(self):
     msg = {
         'title':
         'Airflow dingding single actionCard message',
         'text':
         'Airflow dingding single actionCard message\n'
         '![logo](http://airflow.apache.org/_images/pin_large.png)\n'
         'This is a official logo in Airflow website.',
         'hideAvatar':
         '0',
         'btnOrientation':
         '0',
         'singleTitle':
         'read more',
         'singleURL':
         'http://airflow.apache.org'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'actionCard',
         'message': msg
     }
     expect = {'msgtype': 'actionCard', 'actionCard': msg}
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #3
0
 def test_build_multi_action_card_message(self):
     msg = {
         'title':
         'Airflow dingding multi actionCard message',
         'text':
         'Airflow dingding multi actionCard message\n'
         '![logo](http://airflow.apache.org/_images/pin_large.png)\n'
         'Airflow documentation and github',
         'hideAvatar':
         '0',
         'btnOrientation':
         '0',
         'btns': [{
             'title': 'Airflow Documentation',
             'actionURL': 'http://airflow.apache.org'
         }, {
             'title': 'Airflow Github',
             'actionURL': 'https://github.com/apache/airflow'
         }]
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'actionCard',
         'message': msg
     }
     expect = {'msgtype': 'actionCard', 'actionCard': msg}
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #4
0
 def test_build_markdown_message_remind_all(self):
     msg = {
         'title':
         'Airflow dingding markdown message',
         'text':
         '# Markdown message title\ncontent content .. \n### sub-title\n'
         '![logo](http://airflow.apache.org/_images/pin_large.png)'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'markdown',
         'message': msg,
         'at_all': True,
     }
     expect = {
         'msgtype': 'markdown',
         'markdown': msg,
         'at': {
             'atMobiles': None,
             'isAtAll': True
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #5
0
 def test_build_feed_card_message(self):
     msg = {
         "links": [
             {
                 "title": "Airflow DAG feed card",
                 "messageURL": "https://airflow.readthedocs.io/en/latest/ui.html",
                 "picURL": "http://airflow.apache.org/_images/dags.png"
             },
             {
                 "title": "Airflow tree feed card",
                 "messageURL": "https://airflow.readthedocs.io/en/latest/ui.html",
                 "picURL": "http://airflow.apache.org/_images/tree.png"
             },
             {
                 "title": "Airflow graph feed card",
                 "messageURL": "https://airflow.readthedocs.io/en/latest/ui.html",
                 "picURL": "http://airflow.apache.org/_images/graph.png"
             }
         ]
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'feedCard',
         'message': msg
     }
     expect = {
         'msgtype': 'feedCard',
         'feedCard': msg
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #6
0
 def test_build_multi_action_card_message(self):
     msg = {
         'title': 'Airflow dingding multi actionCard message',
         'text': 'Airflow dingding multi actionCard message\n'
                 '![logo](http://airflow.apache.org/_images/pin_large.png)\n'
                 'Airflow documentation and github',
         'hideAvatar': '0',
         'btnOrientation': '0',
         'btns': [
             {
                 'title': 'Airflow Documentation',
                 'actionURL': 'http://airflow.apache.org'
             },
             {
                 'title': 'Airflow Github',
                 'actionURL': 'https://github.com/apache/airflow'
             }
         ]
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'actionCard',
         'message': msg
     }
     expect = {
         'msgtype': 'actionCard',
         'actionCard': msg
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #7
0
 def test_build_link_message(self):
     msg = {
         'title': 'Airflow dingding link message',
         'text': 'Airflow official documentation link',
         'messageUrl': 'http://airflow.apache.org',
         'picURL': 'http://airflow.apache.org/_images/pin_large.png'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'link',
         'message': msg
     }
     expect = {'msgtype': 'link', 'link': msg}
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #8
0
 def test_build_link_message(self):
     msg = {
         'title': 'Airflow dingding link message',
         'text': 'Airflow official documentation link',
         'messageUrl': 'http://airflow.apache.org',
         'picURL': 'http://airflow.apache.org/_images/pin_large.png'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'link',
         'message': msg
     }
     expect = {
         'msgtype': 'link',
         'link': msg
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #9
0
 def test_build_text_message_remind_all(self):
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'text',
         'message': 'Airflow dingding text message remind all user in group',
         'at_all': True,
     }
     expect = {
         'msgtype': 'text',
         'text': {
             'content': 'Airflow dingding text message remind all user in group'
         },
         'at': {
             'atMobiles': None,
             'isAtAll': True
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #10
0
 def test_build_text_message_remind_all(self):
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'text',
         'message': 'Airflow dingding text message remind all user in group',
         'at_all': True,
     }
     expect = {
         'msgtype': 'text',
         'text': {
             'content': 'Airflow dingding text message remind all user in group'
         },
         'at': {
             'atMobiles': None,
             'isAtAll': True
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #11
0
 def test_build_text_message_remind_specific(self):
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'text',
         'message': 'Airflow dingding text message remind specific users',
         'at_mobiles': ['1234', '5768'],
         'at_all': False,
     }
     expect = {
         'msgtype': 'text',
         'text': {
             'content': 'Airflow dingding text message remind specific users'
         },
         'at': {
             'atMobiles': ['1234', '5768'],
             'isAtAll': False
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #12
0
 def test_build_text_message_remind_specific(self):
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'text',
         'message': 'Airflow dingding text message remind specific users',
         'at_mobiles': ['1234', '5768'],
         'at_all': False,
     }
     expect = {
         'msgtype': 'text',
         'text': {
             'content': 'Airflow dingding text message remind specific users'
         },
         'at': {
             'atMobiles': ['1234', '5768'],
             'isAtAll': False
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #13
0
 def test_build_single_action_card_message(self):
     msg = {
         'title': 'Airflow dingding single actionCard message',
         'text': 'Airflow dingding single actionCard message\n'
                 '![logo](http://airflow.apache.org/_images/pin_large.png)\n'
                 'This is a official logo in Airflow website.',
         'hideAvatar': '0',
         'btnOrientation': '0',
         'singleTitle': 'read more',
         'singleURL': 'http://airflow.apache.org'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'actionCard',
         'message': msg
     }
     expect = {
         'msgtype': 'actionCard',
         'actionCard': msg
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)
コード例 #14
0
 def test_build_markdown_message_remind_all(self):
     msg = {
         'title': 'Airflow dingding markdown message',
         'text': '# Markdown message title\ncontent content .. \n### sub-title\n'
                 '![logo](http://airflow.apache.org/_images/pin_large.png)'
     }
     config = {
         'dingding_conn_id': self.conn_id,
         'message_type': 'markdown',
         'message': msg,
         'at_all': True,
     }
     expect = {
         'msgtype': 'markdown',
         'markdown': msg,
         'at': {
             'atMobiles': None,
             'isAtAll': True
         }
     }
     hook = DingdingHook(**config)
     message = hook._build_message()
     self.assertEqual(json.dumps(expect), message)