How to use the gokart.slack.slack_api.ChannelListNotLoadedError function in gokart

To help you get started, we’ve selected a few gokart examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github m3dev / gokart / test / slack / test_slack_api.py View on Github external
def test_initialization_with_invalid_token(self, patch):
        def _channels_list(method, http_verb="POST", params={}):
            assert method == 'channels.list'
            return {'ok': False, 'error': 'error_reason'}

        mock_client = MagicMock()
        mock_client.api_call = MagicMock(side_effect=_channels_list)
        patch.return_value = mock_client

        with self.assertRaises(gokart.slack.slack_api.ChannelListNotLoadedError):
            gokart.slack.SlackAPI(token='invalid', channel='test', to_user='test user')
github m3dev / gokart / gokart / slack / slack_api.py View on Github external
def _get_channels(self, channels=[], cursor=None):
        params = {}
        if cursor:
            params['cursor'] = cursor
        response = self._client.api_call('channels.list', http_verb="GET", params=params)
        if not response['ok']:
            raise ChannelListNotLoadedError(f'Error while loading channels. The error reason is "{response["error"]}".')
        channels += response.get('channels', [])
        if not channels:
            raise ChannelListNotLoadedError('Channel list is empty.')
        if response['response_metadata']['next_cursor']:
            return self._get_channels(channels, response['response_metadata']['next_cursor'])
        else:
            return channels
github m3dev / gokart / gokart / slack / slack_api.py View on Github external
def _get_channels(self, channels=[], cursor=None):
        params = {}
        if cursor:
            params['cursor'] = cursor
        response = self._client.api_call('channels.list', http_verb="GET", params=params)
        if not response['ok']:
            raise ChannelListNotLoadedError(f'Error while loading channels. The error reason is "{response["error"]}".')
        channels += response.get('channels', [])
        if not channels:
            raise ChannelListNotLoadedError('Channel list is empty.')
        if response['response_metadata']['next_cursor']:
            return self._get_channels(channels, response['response_metadata']['next_cursor'])
        else:
            return channels