-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54577 from garethgreenaway/2019_2_1_port_52715
[master] Porting #52715 to master
- Loading branch information
Showing
1 changed file
with
12 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
:codeauthor: Jayesh Kariya <[email protected]> | ||
:codeauthor: Gareth J. Greenaway <[email protected]> | ||
''' | ||
# Import Python libs | ||
from __future__ import absolute_import, unicode_literals, print_function | ||
|
@@ -42,8 +43,7 @@ def test_post_message_apikey(self): | |
'comment': ''} | ||
|
||
with patch.dict(slack.__opts__, {'test': True}): | ||
comt = ('The following message is to be sent to Slack: {0}' | ||
.format(message)) | ||
comt = 'The following message is to be sent to Slack: {0}'.format(message) | ||
ret.update({'comment': comt}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -52,31 +52,31 @@ def test_post_message_apikey(self): | |
api_key=api_key), ret) | ||
|
||
with patch.dict(slack.__opts__, {'test': False}): | ||
comt = ('Please specify api_key or webhook.') | ||
comt = 'Please specify api_key or webhook.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=None, | ||
from_name=from_name, | ||
message=message, | ||
api_key=None), ret) | ||
|
||
comt = ('Slack channel is missing.') | ||
comt = 'Slack channel is missing.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=None, | ||
from_name=from_name, | ||
message=message, | ||
api_key=api_key), ret) | ||
|
||
comt = ('Slack from name is missing.') | ||
comt = 'Slack from name is missing.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
from_name=None, | ||
message=message, | ||
api_key=api_key), ret) | ||
|
||
comt = ('Slack message is missing.') | ||
comt = 'Slack message is missing.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -86,7 +86,7 @@ def test_post_message_apikey(self): | |
|
||
mock = MagicMock(return_value=True) | ||
with patch.dict(slack.__salt__, {'slack.post_message': mock}): | ||
comt = ('Sent message: slack-message') | ||
comt = 'Sent message: slack-message' | ||
ret.update({'comment': comt, 'result': True}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -112,8 +112,7 @@ def test_post_message_webhook(self): | |
'comment': ''} | ||
|
||
with patch.dict(slack.__opts__, {'test': True}): | ||
comt = ('The following message is to be sent to Slack: {0}' | ||
.format(message)) | ||
comt = 'The following message is to be sent to Slack: {0}'.format(message) | ||
ret.update({'comment': comt}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -122,15 +121,15 @@ def test_post_message_webhook(self): | |
webhook=webhook), ret) | ||
|
||
with patch.dict(slack.__opts__, {'test': False}): | ||
comt = ('Please specify api_key or webhook.') | ||
comt = 'Please specify api_key or webhook.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
username=username, | ||
message=None, | ||
webhook=None), ret) | ||
|
||
comt = ('Please specify only either api_key or webhook.') | ||
comt = 'Please specify only either api_key or webhook.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -139,7 +138,7 @@ def test_post_message_webhook(self): | |
api_key=api_key, | ||
webhook=webhook), ret) | ||
|
||
comt = ('Slack message is missing.') | ||
comt = 'Slack message is missing.' | ||
ret.update({'comment': comt, 'result': False}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|
@@ -149,7 +148,7 @@ def test_post_message_webhook(self): | |
|
||
mock = MagicMock(return_value=True) | ||
with patch.dict(slack.__salt__, {'slack.call_hook': mock}): | ||
comt = ('Sent message: slack-message') | ||
comt = 'Sent message: slack-message' | ||
ret.update({'comment': comt, 'result': True}) | ||
self.assertDictEqual(slack.post_message(name, | ||
channel=channel, | ||
|