def integration_test_execute_real(self): actor = slack.Message( 'Unit Test Action', {'message': self.message, 'channel': self.channel}) res = yield actor.execute() self.assertEquals(res, None)
def integration_test_execute_invalid_room(self): actor = slack.Message( 'Unit Test Action', {'message': self.message, 'channel': "#bad_channel"}) with self.assertRaises(exceptions.RecoverableActorFailure): yield actor.execute()
def test_execute_csv_rooms(self): actor = slack.Message('Unit test message', { 'channel': '#testing, #testing2', 'message': 'Unittest' }) actor._slack_client = self._slack_mock # Mock out the calls to SlackAPI.chat_postMessage().http_post() post_mock = mock.MagicMock() post_mock.http_post.side_effect = mock_tornado({'ok': 'true'}) self._slack_mock.chat_postMessage.return_value = post_mock ret = yield actor._execute() self.assertEquals(None, ret) # Ensure the calls were made to the API post_mock.http_post.assert_has_calls([ mock.call(username='******', unfurl_links=True, text='Unittest', unfurl_media=True, parse='none', link_names=1, channel='#testing') ])
def integration_test_init_without_environment_creds(self): # Un-set the token now and make sure the init fails slack.TOKEN = None with self.assertRaises(exceptions.InvalidCredentials): slack.Message( 'Unit Test Action', {'message': self.message, 'channel': self.channel}, dry=True) # Reload the slack library to re-get the token reload(slack)
def setUp(self, *args, **kwargs): # For most cases, mock out the TOKEN super(TestMessage, self).setUp(*args, **kwargs) slack.TOKEN = 'Unittest' self.actor = slack.Message( 'Unit test message', {'channel': '#testing', 'message': 'Unittest'}) self._slack_mock = mock.MagicMock(name='SlackAPIMock') self.actor._slack_client = self._slack_mock
def integration_test_execute_with_invalid_creds(self): # Un-set the token now and make sure the init fails slack.TOKEN = 'unittest' actor = slack.Message( 'Unit Test Action', {'message': self.message, 'channel': self.channel}, dry=True) # Valid response test actor._token = 'Invalid' with self.assertRaises(exceptions.InvalidCredentials): yield actor.execute() # Reload the slack library to re-get the token reload(slack)