aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_command_reply.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-03-18 00:26:46 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-03-18 01:02:54 +0100
commit8e13b38200f83d4a6fde15188aa00f7679eb17d7 (patch)
treed3ec7fb6587b87cb96120f209aaf836ed252a597 /_pytest/test_command_reply.py
parentf61e946f647b797e4268405df8160dae818e19ab (diff)
downloadwee-slack-8e13b38200f83d4a6fde15188aa00f7679eb17d7.tar.gz
Reply to parent message if trying to reply to thread message
Opening a thread on a thread message is not possible, so the logical thing to do if a user tries to reply to a thread message is to put the message in the same thread as the message that is replied to. Slack currently has a bug which causes thread messages to be converted to normal messages if you try to reply to them (that is, send a message with thread_ts set to the ts of the thread message), but the message you reply with will end up in the original thread. I filed an issue and they confirmed that it is a bug, and that you should not send messages with thread_ts set to the ts of a thread message. Fixes #751
Diffstat (limited to '_pytest/test_command_reply.py')
-rw-r--r--_pytest/test_command_reply.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/_pytest/test_command_reply.py b/_pytest/test_command_reply.py
new file mode 100644
index 0000000..bbff617
--- /dev/null
+++ b/_pytest/test_command_reply.py
@@ -0,0 +1,25 @@
+from __future__ import print_function, unicode_literals
+
+import json
+
+from wee_slack import SlackTS, command_reply
+
+parent_ts = SlackTS('1485975824.000004')
+child_ts = SlackTS('1485975835.000005')
+
+def test_replying_to_child_should_use_parent_ts(realish_eventrouter, team, channel_general):
+ datafiles = [
+ '_pytest/data/websocket/1485975824.48-message.json',
+ '_pytest/data/websocket/1485975836.23-message.json'
+ ]
+ for datafile in datafiles:
+ data = json.loads(open(datafile).read())
+ team.ws.add(data)
+ realish_eventrouter.receive_ws_callback(team.team_hash, None)
+ realish_eventrouter.handle_next()
+
+ child_hash = channel_general.hash_message(child_ts)
+ command_reply(None, channel_general.channel_buffer, '${} test'.format(child_hash))
+
+ sent = json.loads(team.ws.sentdata[0])
+ assert sent['thread_ts'] == parent_ts