aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_command_reply.py
blob: f78e0c7d14b5883cd4064c58b9e1d5db3a7bb3bc (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
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.hashed_messages[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