-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathteams_mock.py
182 lines (169 loc) · 5.95 KB
/
teams_mock.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import json
class MockTeamsAPI:
@classmethod
def list_webhooks(cls):
response = {
"items": [
{
"id": "someID",
"name": "My Awesome Webhook",
"targetUrl": "https://example.com/mywebhook",
"resource": "messages",
"event": "created",
"filter": "roomId=someroomID",
"secret": "86dacc007724d8ea666f88fc77d918dad9537a15",
"status": "active",
"created": "2015-10-18T14:26:16+00:00",
}
]
}
return response
@classmethod
def list_webhooks_exist(cls):
data = MockTeamsAPI.list_webhooks()
data["items"][0]["name"] = "testbot"
return data
@classmethod
def create_webhook(cls):
response = {
"id": "newwebhook",
"name": "My Awesome Webhook",
"targetUrl": "https://example.com/mywebhook",
"resource": "messages",
"event": "created",
"filter": "roomId=someRoomId",
"secret": "86dacc007724d8ea666f88fc77d918dad9537a15",
"status": "active",
"created": "2015-10-18T14:26:16+00:00",
}
return response
@classmethod
def incoming_msg(cls):
data = {
"id": "asdfadfsadfasdf",
"name": "New message in 'Project Unicorn' room",
"resource": "messages",
"event": "created",
"filter": "roomId=sadfasdfsdffsadfd",
"orgId": "OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNkYzlh",
"createdBy": "fdsafdsf",
"appId": "asdfasdfsadf",
"ownedBy": "creator",
"status": "active",
"actorId": "asdffsdfsdsafd",
"data": {
"id": "incoming_message_id",
"roomId": "some_room_id",
"personId": "some_person_id",
"personEmail": "[email protected]",
"created": "2015-10-18T14:26:16.000Z",
},
}
return json.dumps(data)
@classmethod
def incoming_membership_fail(cls):
data = {
'id': 'newwebhook',
'name': 'My Awesome Webhook',
'targetUrl': 'https://example.com/mywebhook',
'resource': 'memberships',
'event': 'created',
'orgId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNkYzlh',
'createdBy': 'fdsafdsf',
'appId': 'asdfasdfsadf',
'ownedBy': 'creator',
'status': 'active',
'created': '2018-09-13T19:35:51.248Z',
'actorId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNkYzlh',
'data': {
'id': 'incoming_membership_id',
'roomId': 'some_room_id',
'personId': 'some_person_id',
'personEmail': '[email protected]',
'personDisplayName': 'Matt',
'personOrgId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNk',
'isModerator': False,
'isMonitor': False,
'created': '2018-09-13T19:35:58.803Z'
}
}
return json.dumps(data)
@classmethod
def incoming_membership_pass(cls):
data = {
'id': 'newwebhook',
'name': 'My Awesome Webhook',
'targetUrl': 'https://example.com/mywebhook',
'resource': 'memberships',
'event': 'created',
'orgId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNkYzlh',
'createdBy': 'fdsafdsf',
'appId': 'asdfasdfsadf',
'ownedBy': 'creator',
'status': 'active',
'created': '2018-09-13T19:35:51.248Z',
'actorId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNkYzlh',
'data': {
'id': 'incoming_membership_id',
'roomId': 'some_room_id',
'personId': 'some_person_id',
'personEmail': '[email protected]',
'personDisplayName': 'Matt',
'personOrgId': 'OTZhYmMyYWEtM2RjYy0xMWU1LWExNTItZmUzNDgxOWNk',
'isModerator': False,
'isMonitor': False,
'created': '2018-09-13T19:35:58.803Z'
}
}
return json.dumps(data)
@classmethod
def get_message_help(cls):
data = {
"id": "some_message_id",
"roomId": "some_room_id",
"roomType": "group",
"toPersonId": "some_person_id",
"toPersonEmail": "[email protected]",
"text": "/help",
"personEmail": "[email protected]",
"personId": "some_person_id",
"created": "2015-10-18T14:26:16+00:00",
}
return data
# @classmethod
# def get_message_echo(cls):
# data = MockTeamsAPI.get_message_help()
# data['text'] = "/echo foo"
# return data
@classmethod
def empty_message(cls):
data = MockTeamsAPI.get_message_help()
data["text"] = ""
return data
@classmethod
def get_message_dosomething(cls):
data = MockTeamsAPI.get_message_help()
data["text"] = "/echo imtheecho"
return data
@classmethod
def get_message_from_bot(cls):
data = MockTeamsAPI.get_message_help()
data["personEmail"] = "[email protected]"
return data
@classmethod
def me(cls):
data = {
"id": "myid",
"emails": ["[email protected]"],
"displayName": "Some User",
"nickName": "SomeUser",
"firstName": "Some",
"lastName": "User",
"avatar": "https://some-avatar-url.com/sdflkjsdflkajs",
"orgId": "orgid",
"created": "2012-06-15T20:32:02.438Z",
"lastActivity": "2018-04-09T21:15:44.677Z",
"status": "inactive",
"type": "person",
}
return data