zulip_bots: Add test for get_alert_id
method of Mention bot.
This commit is contained in:
parent
3d05ed53e5
commit
48e365195e
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"alert": {
|
||||
"id": "112233",
|
||||
"name": "NASA and competitors",
|
||||
"query": {
|
||||
"type": "basic",
|
||||
"included_keywords": [
|
||||
"NASA",
|
||||
"Arianespace",
|
||||
"SpaceX",
|
||||
"Pockocmoc"
|
||||
],
|
||||
"required_keywords": [
|
||||
"mars"
|
||||
],
|
||||
"excluded_keywords": [
|
||||
"nose",
|
||||
"fil d'ariane"
|
||||
]
|
||||
},
|
||||
"languages": [
|
||||
"en",
|
||||
"fr",
|
||||
"ru"
|
||||
],
|
||||
"countries": [],
|
||||
"sources": [
|
||||
"twitter",
|
||||
"news",
|
||||
"web",
|
||||
"blogs",
|
||||
"videos",
|
||||
"forums",
|
||||
"images"
|
||||
],
|
||||
"blocked_sites": [
|
||||
"www.spaceoflovemagazine.com/"
|
||||
],
|
||||
"role": "admin",
|
||||
"stats": {
|
||||
"mention_sources": {
|
||||
"total": "0"
|
||||
},
|
||||
"mention_folders": {
|
||||
"inbox": {
|
||||
"total": "0"
|
||||
},
|
||||
"archive": {
|
||||
"total": "0"
|
||||
},
|
||||
"spam": {
|
||||
"total": "0"
|
||||
},
|
||||
"trash": {
|
||||
"total": "0"
|
||||
}
|
||||
},
|
||||
"unread_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"unseen_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"favorite_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"important_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"todo_tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"done_tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"logs": {
|
||||
"total": "0"
|
||||
}
|
||||
},
|
||||
"shares": [
|
||||
{
|
||||
"id": "THE_ACCOUNT_ID",
|
||||
"account": {
|
||||
"id": "THE_ACCOUNT_ID",
|
||||
"name": "Doe",
|
||||
"email": "john.doe@nasa.com",
|
||||
"language_code": "en",
|
||||
"created_at": "2014-09-30T10:03:54.0+00:00",
|
||||
"updated_at": "2016-01-14T14:55:57.0+00:00",
|
||||
"avatar_url": "https:\/\/d39qsljf883l.cloudfront.net\/f6415b89ef2ljkca5c0c7d464f1b82-088f3dsqlj12lj4.jpg",
|
||||
"timezone": "Europe\/Berlin",
|
||||
"grouped_email_notification": true,
|
||||
"default_email_notification_frequency": "daily",
|
||||
"default_desktop_notification_frequency": "hourly",
|
||||
"default_push_notification_frequency": "hourly"
|
||||
},
|
||||
"role": "admin",
|
||||
"permissions": {
|
||||
"edit": true,
|
||||
"delete": true
|
||||
},
|
||||
"created_at": "2016-01-14T15:31:42.0+00:00",
|
||||
"weight": 88674800
|
||||
}
|
||||
],
|
||||
"noise_detection": true,
|
||||
"created_at": "2016-01-14T15:31:42.0+00:00",
|
||||
"updated_at": "2016-01-14T15:31:44.0+00:00",
|
||||
"quota_used": 0,
|
||||
"index_version": 2,
|
||||
"permissions": {
|
||||
"edit": true,
|
||||
"share": true,
|
||||
"list_tasks": true,
|
||||
"list_logs": true
|
||||
},
|
||||
"description": "Monitor NASA press release.",
|
||||
"color": "#05e363",
|
||||
"connection_type": "related",
|
||||
"connection_id": "12121212"
|
||||
}
|
||||
}
|
170
zulip_bots/zulip_bots/bots/mention/fixtures/get_alert_id.json
Normal file
170
zulip_bots/zulip_bots/bots/mention/fixtures/get_alert_id.json
Normal file
|
@ -0,0 +1,170 @@
|
|||
{
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"api_url": "https://api.mention.net/api/accounts/TEST/alerts",
|
||||
"headers": {
|
||||
"Authorization": "Bearer TEST",
|
||||
"Content-Type": "application/json",
|
||||
"Accept-Version": "1.15"
|
||||
},
|
||||
"data": {
|
||||
"name": "TEST",
|
||||
"query": {
|
||||
"type": "basic",
|
||||
"included_keywords": [
|
||||
"TEST"
|
||||
]
|
||||
},
|
||||
"languages": [
|
||||
"en"
|
||||
],
|
||||
"sources": [
|
||||
"web"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"alert": {
|
||||
"id": "TEST",
|
||||
"name": "NASA and competitors",
|
||||
"query": {
|
||||
"type": "basic",
|
||||
"included_keywords": [
|
||||
"NASA",
|
||||
"Arianespace",
|
||||
"SpaceX",
|
||||
"Pockocmoc"
|
||||
],
|
||||
"required_keywords": [
|
||||
"mars"
|
||||
],
|
||||
"excluded_keywords": [
|
||||
"nose",
|
||||
"fil d'ariane"
|
||||
]
|
||||
},
|
||||
"languages": [
|
||||
"en",
|
||||
"fr",
|
||||
"ru"
|
||||
],
|
||||
"countries": [],
|
||||
"sources": [
|
||||
"twitter",
|
||||
"news",
|
||||
"web",
|
||||
"blogs",
|
||||
"videos",
|
||||
"forums",
|
||||
"images"
|
||||
],
|
||||
"blocked_sites": [
|
||||
"www.spaceoflovemagazine.com/"
|
||||
],
|
||||
"role": "admin",
|
||||
"stats": {
|
||||
"mention_sources": {
|
||||
"total": "0"
|
||||
},
|
||||
"mention_folders": {
|
||||
"inbox": {
|
||||
"total": "0"
|
||||
},
|
||||
"archive": {
|
||||
"total": "0"
|
||||
},
|
||||
"spam": {
|
||||
"total": "0"
|
||||
},
|
||||
"trash": {
|
||||
"total": "0"
|
||||
}
|
||||
},
|
||||
"unread_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"unseen_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"favorite_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"important_mentions": {
|
||||
"total": "0"
|
||||
},
|
||||
"tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"todo_tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"done_tasks": {
|
||||
"total": "0"
|
||||
},
|
||||
"logs": {
|
||||
"total": "0"
|
||||
}
|
||||
},
|
||||
"shares": [
|
||||
{
|
||||
"id": "THE_ACCOUNT_ID",
|
||||
"account": {
|
||||
"id": "THE_ACCOUNT_ID",
|
||||
"name": "Doe",
|
||||
"email": "john.doe@nasa.com",
|
||||
"language_code": "en",
|
||||
"created_at": "2014-09-30T10:03:54.0+00:00",
|
||||
"updated_at": "2016-01-14T14:55:57.0+00:00",
|
||||
"avatar_url": "https:\/\/d39qsljf883l.cloudfront.net\/f6415b89ef2ljkca5c0c7d464f1b82-088f3dsqlj12lj4.jpg",
|
||||
"timezone": "Europe\/Berlin",
|
||||
"grouped_email_notification": true,
|
||||
"default_email_notification_frequency": "daily",
|
||||
"default_desktop_notification_frequency": "hourly",
|
||||
"default_push_notification_frequency": "hourly"
|
||||
},
|
||||
"role": "admin",
|
||||
"permissions": {
|
||||
"edit": true,
|
||||
"delete": true
|
||||
},
|
||||
"created_at": "2016-01-14T15:31:42.0+00:00",
|
||||
"weight": 88674800
|
||||
}
|
||||
],
|
||||
"noise_detection": true,
|
||||
"created_at": "2016-01-14T15:31:42.0+00:00",
|
||||
"updated_at": "2016-01-14T15:31:44.0+00:00",
|
||||
"quota_used": 0,
|
||||
"index_version": 2,
|
||||
"permissions": {
|
||||
"edit": true,
|
||||
"share": true,
|
||||
"list_tasks": true,
|
||||
"list_logs": true
|
||||
},
|
||||
"description": "Monitor NASA press release.",
|
||||
"color": "#05e363",
|
||||
"connection_type": "related",
|
||||
"connection_id": "12121212"
|
||||
}
|
||||
},
|
||||
"response-headers": {
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"X-Upstream2": "mention_backend",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-Protected-By": "Sqreen",
|
||||
"Transfer-Encoding": "chunked",
|
||||
"X-Api-Version": "1.15",
|
||||
"Content-Encoding": "gzip",
|
||||
"Connection": "keep-alive",
|
||||
"Server": "nginx",
|
||||
"Content-Type": "application/json",
|
||||
"Vary": "Accept-Encoding, Accept-Language, X-Accept-Language",
|
||||
"Set-Cookie": "www_bucket=55; Expires=Tue, 30 Jan 2018 10:59:52 GMT; Domain=mention.com; Path=/",
|
||||
"Date": "Sun, 31 Dec 2017 10:59:52 GMT",
|
||||
"X-Frame-Options": "SAMEORIGIN",
|
||||
"Cache-Control": "no-cache, private",
|
||||
"Referrer-Policy": "same-origin",
|
||||
"X-S": "web16"
|
||||
}
|
||||
}
|
|
@ -22,3 +22,11 @@ class TestMentionBot(BotTestCase):
|
|||
|
||||
with self.mock_http_conversation('get_account_id'):
|
||||
self.assertEqual(bot_test_instance.get_account_id(), 'TEST')
|
||||
|
||||
def test_get_alert_id(self) -> None:
|
||||
bot_test_instance = MentionHandler()
|
||||
bot_test_instance.access_token = 'TEST'
|
||||
bot_test_instance.account_id = 'TEST'
|
||||
|
||||
with self.mock_http_conversation('get_alert_id'):
|
||||
self.assertEqual(bot_test_instance.get_alert_id('TEST'), 'TEST')
|
||||
|
|
Loading…
Reference in a new issue