aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_thread.py
blob: 4095e776ff8c627835986e13b8aea637a6b0e8a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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, None)
    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, None)
    realish_eventrouter.handle_next()

    message_text = channel_general.messages[thread_ts].message_json['_rendered_text']
    assert message_text == 'generally, yep! <[color lightcyan]>[ Thread: 309 Replies: 1 ]<[color reset]>'

    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, None)
    realish_eventrouter.handle_next()

    message_text = channel_general.messages[thread_ts].message_json['_rendered_text']
    assert message_text == 'generally, yep! <[color lightcyan]>[ Thread: 309 Replies: 2 ]<[color reset]>'