aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_topic_command.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-04-02 09:58:56 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-04-08 15:11:57 +0200
commitb459586d96ec1f765d7aed86538b8d8576977f6c (patch)
tree63488459b22c11b83589b9cfe562f58b4c701b57 /_pytest/test_topic_command.py
parent82147d2d2a47927528e993816ee9393a4aa15b83 (diff)
downloadwee-slack-b459586d96ec1f765d7aed86538b8d8576977f6c.tar.gz
Cleanup tests and make them compatible with python 3
This mainly adds team, channel_general and user_alice as fixtures, so we can use those directly instead of picking arbitrary ones from the lists. It also adds assertions to some tests which where missing it.
Diffstat (limited to '_pytest/test_topic_command.py')
-rw-r--r--_pytest/test_topic_command.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/_pytest/test_topic_command.py b/_pytest/test_topic_command.py
index c8dc8a3..c632148 100644
--- a/_pytest/test_topic_command.py
+++ b/_pytest/test_topic_command.py
@@ -48,10 +48,8 @@ def test_parse_topic_with_channel_and_delete():
assert topic == ''
-def test_call_topic_without_arguments(realish_eventrouter):
- team = realish_eventrouter.teams.values()[-1]
- channel = team.channels.values()[-1]
- current_buffer = channel.channel_buffer
+def test_call_topic_without_arguments(realish_eventrouter, channel_general):
+ current_buffer = channel_general.channel_buffer
wee_slack.EVENTROUTER = realish_eventrouter
command = '/topic'
@@ -59,16 +57,14 @@ def test_call_topic_without_arguments(realish_eventrouter):
with patch('wee_slack.w.prnt') as fake_prnt:
result = topic_command_cb(None, current_buffer, command)
fake_prnt.assert_called_with(
- channel.channel_buffer,
- 'Topic for {} is "{}"'.format(channel.name, channel.topic),
+ channel_general.channel_buffer,
+ 'Topic for {} is "{}"'.format(channel_general.name, channel_general.topic),
)
assert result == wee_slack.w.WEECHAT_RC_OK_EAT
-def test_call_topic_with_unknown_channel(realish_eventrouter):
- team = realish_eventrouter.teams.values()[-1]
- channel = team.channels.values()[-1]
- current_buffer = channel.channel_buffer
+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'
@@ -82,10 +78,8 @@ def test_call_topic_with_unknown_channel(realish_eventrouter):
assert result == wee_slack.w.WEECHAT_RC_OK_EAT
-def test_call_topic_with_channel_and_string(realish_eventrouter):
- team = realish_eventrouter.teams.values()[-1]
- channel = team.channels.values()[-1]
- current_buffer = channel.channel_buffer
+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'
@@ -94,5 +88,5 @@ def test_call_topic_with_channel_and_string(realish_eventrouter):
request = realish_eventrouter.queue[-1]
assert request.request == 'channels.setTopic'
assert request.post_data == {
- 'channel': 'C407ABS94', 'token': 'xoxoxoxox', 'topic': 'new topic'}
+ 'channel': 'C407ABS94', 'token': 'xoxs-token', 'topic': 'new topic'}
assert result == wee_slack.w.WEECHAT_RC_OK_EAT