diff options
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/data/http/rtm.start.json | 36 | ||||
-rw-r--r-- | _pytest/data/websocket/1483975206.59-subteam_created.json | 24 | ||||
-rw-r--r-- | _pytest/data/websocket/1483975206.59-subteam_updated.json | 34 | ||||
-rw-r--r-- | _pytest/test_linkifytext.py | 11 | ||||
-rw-r--r-- | _pytest/test_processsubteamcreated.py | 22 | ||||
-rw-r--r-- | _pytest/test_processsubteamupdated.py | 29 | ||||
-rw-r--r-- | _pytest/test_unfurl.py | 4 |
7 files changed, 158 insertions, 2 deletions
diff --git a/_pytest/data/http/rtm.start.json b/_pytest/data/http/rtm.start.json index 34d875a..2d0a36a 100644 --- a/_pytest/data/http/rtm.start.json +++ b/_pytest/data/http/rtm.start.json @@ -673,8 +673,40 @@ "read_only_channels": [], "can_manage_shared_channels": false, "subteams": { - "self": [], - "all": [] + "all": [ + { + "auto_provision": false, + "auto_type": null, + "created_by": "X786CTH5L", + "date_create": 1541837133, + "date_delete": 0, + "date_update": 1511887378, + "deleted_by": null, + "description": "Sample subteam / subgroup", + "enterprise_subteam_id": "S01", + "handle": "test", + "id": "TGX0ALBK3", + "is_external": false, + "is_subteam": true, + "is_usergroup": true, + "name": "Sample Usergroup", + "prefs": { + "channels": [ + "A7BC8UX4Z" + ], + "groups": [ + "I78T9MC86" + ] + }, + "team_id": "T6SH3PWP9", + "updated_by": "X786CTH5L", + "user_count": 4 + } + ], + + "self": [ + "TGX0ALBK3" + ] }, "dnd": { "dnd_enabled": true, diff --git a/_pytest/data/websocket/1483975206.59-subteam_created.json b/_pytest/data/websocket/1483975206.59-subteam_created.json new file mode 100644 index 0000000..af42a0f --- /dev/null +++ b/_pytest/data/websocket/1483975206.59-subteam_created.json @@ -0,0 +1,24 @@ +{ + "subteam": { + "auto_type": null, + "created_by": "U060RNRCZ", + "date_create": 1446746793, + "date_delete": 0, + "date_update": 1446746793, + "deleted_by": null, + "description": "Marketing gurus, PR experts and product advocates.", + "handle": "marketing-team", + "id": "S0615G0KT", + "is_external": false, + "is_usergroup": true, + "name": "Marketing Team", + "prefs": { + "channels": [], + "groups": [] + }, + "team_id": "T060RNRCH", + "updated_by": "U060RNRCZ", + "user_count": "0" + }, + "type": "subteam_created" +} diff --git a/_pytest/data/websocket/1483975206.59-subteam_updated.json b/_pytest/data/websocket/1483975206.59-subteam_updated.json new file mode 100644 index 0000000..4b5c03e --- /dev/null +++ b/_pytest/data/websocket/1483975206.59-subteam_updated.json @@ -0,0 +1,34 @@ +{ + "type": "subteam_updated", + "subteam": { + "id": "TGX0ALBK3", + "team_id": "T6SH3PWP9", + "is_usergroup": true, + "name": "Sample Usergroup Modified", + "description": "Sample subteam modified", + "handle": "test_modified", + "is_external": false, + "date_create": 1446598059, + "date_update": 1446670362, + "date_delete": 0, + "auto_type": "admin", + "created_by": "X786CTH5L", + "updated_by": "U060RNRCZ", + "deleted_by": null, + "prefs": { + "channels": [ + + ], + "groups": [ + + ] + }, + "users": [ + "U060RNRCZ", + "U060ULRC0", + "U06129G2V", + "U061309JM" + ], + "user_count": "4" + } +} diff --git a/_pytest/test_linkifytext.py b/_pytest/test_linkifytext.py index da1586e..fea6ab8 100644 --- a/_pytest/test_linkifytext.py +++ b/_pytest/test_linkifytext.py @@ -53,6 +53,17 @@ def test_linkifytext_names_with_apostrophe(realish_eventrouter): assert text == '@O\'Connor: my test message' +def test_linkifytext_names_with_subgroup_notification(realish_eventrouter): + subteam_id = "TGX0ALBK3" + handle = "test" + team = realish_eventrouter.teams.values()[0] + channel = team.channels.values()[0] + + message = 'This is a message for the test team' + text = linkify_text('@test: {}'.format(message), team) + + assert text == '<!subteam^{}|@{}>: {}'.format(subteam_id, handle, message) + def test_linkifytext_at_channel(realish_eventrouter): team = realish_eventrouter.teams.values()[0] diff --git a/_pytest/test_processsubteamcreated.py b/_pytest/test_processsubteamcreated.py new file mode 100644 index 0000000..7d403db --- /dev/null +++ b/_pytest/test_processsubteamcreated.py @@ -0,0 +1,22 @@ +import glob +import json + +def test_process_subteam_created(mock_websocket, realish_eventrouter): + + eventrouter = realish_eventrouter + + t = eventrouter.teams.keys()[0] + + assert len(eventrouter.teams[t].subteams) == 1 + + socket = mock_websocket + eventrouter.teams[t].ws = socket + datafiles = glob.glob("_pytest/data/websocket/1483975206.59-subteam_created.json") + + for fname in datafiles: + data = json.loads(open(fname, 'r').read()) + socket.add(data) + eventrouter.receive_ws_callback(t) + eventrouter.handle_next() + + assert len(eventrouter.teams[t].subteams) == 2 diff --git a/_pytest/test_processsubteamupdated.py b/_pytest/test_processsubteamupdated.py new file mode 100644 index 0000000..34fd302 --- /dev/null +++ b/_pytest/test_processsubteamupdated.py @@ -0,0 +1,29 @@ +import glob +from mock import patch, call +from wee_slack import SlackTeam, SlackSubteam +import json + +def test_process_subteam_self_updated(mock_websocket, realish_eventrouter): + + eventrouter = realish_eventrouter + + t = eventrouter.teams.keys()[0] + + assert len(eventrouter.teams[t].subteams) == 1 + + socket = mock_websocket + eventrouter.teams[t].ws = socket + datafiles = glob.glob("_pytest/data/websocket/1483975206.59-subteam_updated.json") + + for fname in datafiles: + data = json.loads(open(fname, 'r').read()) + socket.add(data) + eventrouter.receive_ws_callback(t) + eventrouter.handle_next() + team = eventrouter.teams[t] + subteam = team.subteams.values()[0] + + assert data['subteam']['handle'] == subteam.handle + assert data['subteam']['description'] == subteam.description + assert data['subteam']['name'] == subteam.name + diff --git a/_pytest/test_unfurl.py b/_pytest/test_unfurl.py index 40674b4..6b8e84c 100644 --- a/_pytest/test_unfurl.py +++ b/_pytest/test_unfurl.py @@ -62,6 +62,10 @@ slack = wee_slack 'input': "<@U407ABLLW> I think 3 > 2", 'output': "@alice I think 3 > 2", }, + { + 'input': "<!subteam^U407ABLLW|@dev> This is announcement for the dev team", + 'output': "@dev This is announcement for the dev team" + } )) def test_unfurl_refs(case, realish_eventrouter): slack.EVENTROUTER = realish_eventrouter |