How to use slackclient - 10 common examples

To help you get started, we’ve selected a few slackclient 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 slackapi / python-slackclient / tests / test_slackclient.py View on Github external
def test_SlackClient_process_changes(
    slackclient, channel_created_fixture, im_created_fixture
):
    slackclient.process_changes(channel_created_fixture)
    assert type(slackclient.server.channels.find("fun")) == Channel
    slackclient.process_changes(im_created_fixture)
    assert type(slackclient.server.channels.find("U123BL234")) == Channel
github slackapi / python-slackclient / tests / test_channel.py View on Github external
def test_channel_is_hashable(channel):
    channel = Channel(
        'test-server',
        'test-channel',
        'C12345678',
    )
    channel_map = {channel: channel.id}
    assert channel_map[channel] == 'C12345678'
    assert (channel_map[channel] == 'foo') is False
github slackapi / python-slackclient / tests / test_server.py View on Github external
def test_server_parse_channel_data(server, rtm_start_fixture):
    server.parse_channel_data(rtm_start_fixture["channels"])
    assert type(server.channels.find('general')) == Channel
github arcticfoxnv / slackminion / slackminion / utils / test_helpers / slack.py View on Github external
def __init__(self):
        self.server = DummyServer()
        self.server.channels.append(Channel(None, test_channel_name, test_channel_id))
        self.server.channels.append(Channel(None, test_group_name, test_group_id))
        self.server.users.append(User(None, test_user_name, test_user_id, test_user_name, None, test_user_email))
        self.topic = 'Test Topic'
github slackapi / python-slackclient / tests / test_channel.py View on Github external
def test_channel(channel):
    assert type(channel) == Channel
github slackapi / python-slackclient / tests / test_slackrequest.py View on Github external
def test_http_headers(mocker):
    requests = mocker.patch('slackclient.slackrequest.requests')
    request = SlackRequest()

    request.do('xoxb-123', 'chat.postMessage', {'text': 'test', 'channel': '#general'})
    args, kwargs = requests.post.call_args

    assert kwargs['headers']['user-agent'] is not None
github slackapi / python-slackclient / tests / test_slackrequest.py View on Github external
def test_post_attachements(mocker):
    requests = mocker.patch('slackclient.slackrequest.requests')
    request = SlackRequest()

    request.do('xoxb-123',
               'chat.postMessage',
               {'attachments': [{'title': 'hello'}]})
    args, kwargs = requests.post.call_args

    assert requests.post.call_count == 1
    assert 'https://slack.com/api/chat.postMessage' == args[0]
    assert isinstance(kwargs["data"]["attachments"], str)
github slackapi / python-slackclient / tests / test_slackrequest.py View on Github external
def test_post_file(mocker):
    requests = mocker.patch('slackclient.slackrequest.requests')
    request = SlackRequest()

    request.do('xoxb-123',
               'files.upload',
               {'file': open(os.path.join('.', 'tests', 'data', 'slack_logo.png'), 'rb'),
                'filename': 'slack_logo.png'})
    args, kwargs = requests.post.call_args

    assert requests.post.call_count == 1
    assert 'https://slack.com/api/files.upload' == args[0]
    assert {'filename': 'slack_logo.png'} == kwargs['data']
    assert kwargs['files'] is not None
github slackapi / python-slackclient / tests / test_slackrequest.py View on Github external
def test_auth_header(mocker):
    requests = mocker.patch('slackclient.slackrequest.requests')
    request = SlackRequest()

    request.do('xoxb-123', 'chat.postMessage', {'text': 'test', 'channel': '#general'})
    args, kwargs = requests.post.call_args

    assert "Bearer xoxb-123" in kwargs['headers']['Authorization']
github slackapi / python-slackclient / tests / test_slackrequest.py View on Github external
def test_custom_user_agent(mocker):
    requests = mocker.patch('slackclient.slackrequest.requests')
    request = SlackRequest()

    request.append_user_agent("fooagent1", "0.1")
    request.append_user_agent("baragent/2", "0.2")

    request.do('xoxb-123', 'chat.postMessage', {'text': 'test', 'channel': '#general'})
    args, kwargs = requests.post.call_args

    # Verify user-agent includes both default and custom agent info
    assert "slackclient/{}".format(__version__) in kwargs['headers']['user-agent']
    assert "fooagent1/0.1" in kwargs['headers']['user-agent']

    # verify escaping of slashes in custom agent name
    assert "baragent:2/0.2" in kwargs['headers']['user-agent']