Beispiel #1
0
def test_call_topic_with_channel_and_string(realish_eventrouter, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic #general new topic'

    result = topic_command_cb(None, current_buffer, command)
    request = realish_eventrouter.queue[-1]
    assert request.request == 'channels.setTopic'
    assert request.post_data == {
        'channel': 'C407ABS94', 'token': 'xoxs-token', 'topic': 'new topic'}
    assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #2
0
def test_call_topic_with_channel_and_string(realish_eventrouter, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic #general new topic'

    result = topic_command_cb(None, current_buffer, command)
    request = realish_eventrouter.queue[-1]
    assert request.request == 'conversations.setTopic'
    assert request.post_data == {
        'channel': 'C407ABS94', 'token': 'xoxs-token', 'topic': 'new topic'}
    assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #3
0
def test_call_topic_with_unknown_channel(realish_eventrouter, team, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic #nonexisting'

    with patch('wee_slack.w.prnt') as fake_prnt:
        result = topic_command_cb(None, current_buffer, command)
        fake_prnt.assert_called_with(
            team.channel_buffer,
            "#nonexisting: No such channel",
        )
        assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #4
0
def test_call_topic_without_arguments(realish_eventrouter, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic'

    with patch('wee_slack.w.prnt') as fake_prnt:
        result = topic_command_cb(None, current_buffer, command)
        fake_prnt.assert_called_with(
            channel_general.channel_buffer,
            'Topic for {} is "{}"'.format(channel_general.name, channel_general.topic['value']),
        )
        assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #5
0
def test_call_topic_with_unknown_channel(realish_eventrouter, team, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic #nonexisting'

    with patch('wee_slack.w.prnt') as fake_prnt:
        result = topic_command_cb(None, current_buffer, command)
        fake_prnt.assert_called_with(
            team.channel_buffer,
            "#nonexisting: No such channel",
        )
        assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #6
0
def test_call_topic_without_arguments(realish_eventrouter, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = '/topic'

    with patch('wee_slack.w.prnt') as fake_prnt:
        result = topic_command_cb(None, current_buffer, command)
        fake_prnt.assert_called_with(
            channel_general.channel_buffer,
            'Topic for {} is "{}"'.format(channel_general.name, channel_general.topic),
        )
        assert result == wee_slack.w.WEECHAT_RC_OK_EAT
Beispiel #7
0
def test_call_topic_with_channel_and_string(realish_eventrouter, channel_general):
    current_buffer = channel_general.channel_buffer
    wee_slack.EVENTROUTER = realish_eventrouter

    command = "/topic #general new topic"

    result = topic_command_cb(None, current_buffer, command)
    request = realish_eventrouter.queue[-1]
    assert request.request == "conversations.setTopic"
    assert request.post_data == {
        "channel": "C407ABS94",
        "token": "xoxs-token",
        "topic": "new topic",
    }
    assert result == wee_slack.w.WEECHAT_RC_OK_EAT