aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_processteamjoin.py
blob: c7c199fd625adafa11a219c8b85e09ee50c52509 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import glob
import json

from wee_slack import ProcessNotImplemented

def test_process_team_join(mock_websocket, realish_eventrouter):

    eventrouter = realish_eventrouter

    t = eventrouter.teams.keys()[0]
    #u = eventrouter.teams[t].users.keys()[0]

    #user = eventrouter.teams[t].users[u]
    #print user

    #delete charles so we can add him
    del eventrouter.teams[t].users['U4096CBHC']

    assert len(eventrouter.teams[t].users) == 3

    socket = mock_websocket
    eventrouter.teams[t].ws = socket

    datafiles = glob.glob("_pytest/data/websocket/1485975606.59-team_join.json")

    print datafiles
    #assert False

    notimplemented = set()

    for fname in datafiles:
        try:
            print "####################"
            data = json.loads(open(fname, 'r').read())
            socket.add(data)
            print data
            eventrouter.receive_ws_callback(t)
            eventrouter.handle_next()
        except ProcessNotImplemented as e:
            notimplemented.add(str(e))
        #this handles some message data not existing - need to fix
        except KeyError:
            pass

    if len(notimplemented) > 0:
        print "####################"
        print sorted(notimplemented)
        print "####################"

    #print len(eventrouter.queue)
    assert len(eventrouter.teams[t].users) == 4