def test_init_missing_creds(self): # Un-set the token now and make sure the init fails slack.TOKEN = None with self.assertRaises(exceptions.InvalidCredentials): slack.SlackBase('Unit Test Action', {}) # Reload the slack library to re-get the token importlib.reload(slack)
def test_init(self): actor = slack.SlackBase('Unit test action', {}) # Ensure that the actor._slack_client is configured with a dictionary # that contains the token in it. slack_client_tokens = actor._slack_client._client._tokens self.assertEquals(slack_client_tokens, {'token': 'Unittest'})
def test_check_results_with_ok_results(self): actor = slack.SlackBase('Unit test action', {}) results = { "ok": True, "channel": "C03H4GRDF", "ts": "1423092527.000006", "message": { "text": "Hi, testing!", "username": "******", "type": "message", "subtype": "bot_message", "ts": "1423092527.000006" } } self.assertEqual(None, actor._check_results(results))
def test_check_results_with_unexpected_results(self): actor = slack.SlackBase('Unit test action', {}) results = 'got some unexpected result' with self.assertRaises(exceptions.UnrecoverableActorFailure): actor._check_results(results)
def test_check_results_with_invalid_creds(self): actor = slack.SlackBase('Unit test action', {}) results = {'ok': False, 'error': 'invalid_auth'} with self.assertRaises(exceptions.InvalidCredentials): actor._check_results(results)