diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2019-10-03 17:12:28 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-10-03 17:44:10 +0200 |
commit | d3da855bb57f9cf795cab8626dd7f9b089232212 (patch) | |
tree | aac20eee20facd935dad59115aef57b9e6315054 /_pytest/test_thread.py | |
parent | 335040b3df59ed29b1e53c3dade32d4362c2f191 (diff) | |
download | wee-slack-d3da855bb57f9cf795cab8626dd7f9b089232212.tar.gz |
Use max of submessages and replies for number_of_replies
When new replies come in over websocket, we don't update the
message_json of the parent message with the new replies, we just append
the new message to the submessages list. Therefore, the
number_of_replies function has to check both of these and take the max.
Fixes #722
Diffstat (limited to '_pytest/test_thread.py')
-rw-r--r-- | _pytest/test_thread.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/_pytest/test_thread.py b/_pytest/test_thread.py new file mode 100644 index 0000000..1eea31f --- /dev/null +++ b/_pytest/test_thread.py @@ -0,0 +1,37 @@ +from __future__ import print_function, unicode_literals + +import json + +from wee_slack import SlackTS + + +thread_ts = SlackTS('1485975824.000004') + + +def test_message_has_thread_suffix(realish_eventrouter, team, channel_general): + datafile = '_pytest/data/websocket/1485975824.48-message.json' + data = json.loads(open(datafile).read()) + team.ws.add(data) + realish_eventrouter.receive_ws_callback(team.team_hash) + realish_eventrouter.handle_next() + + message_text = channel_general.messages[thread_ts].message_json['_rendered_text'] + assert message_text == 'generally, yep!' + + datafile = '_pytest/data/websocket/1485975836.23-message.json' + data = json.loads(open(datafile).read()) + team.ws.add(data) + realish_eventrouter.receive_ws_callback(team.team_hash) + realish_eventrouter.handle_next() + + message_text = channel_general.messages[thread_ts].message_json['_rendered_text'] + assert message_text == 'generally, yep! [ Thread: 309 Replies: 1 ]' + + datafile = '_pytest/data/websocket/1485975842.1-message.json' + data = json.loads(open(datafile).read()) + team.ws.add(data) + realish_eventrouter.receive_ws_callback(team.team_hash) + realish_eventrouter.handle_next() + + message_text = channel_general.messages[thread_ts].message_json['_rendered_text'] + assert message_text == 'generally, yep! [ Thread: 309 Replies: 2 ]' |