Skip to content

Commit

Permalink
Merge branch 'test-telegram' of 'https://github.com/VSevagen/grimoire…
Browse files Browse the repository at this point in the history
…lab-elk'

Merges #971
Closes #971
  • Loading branch information
sduenas committed Apr 7, 2021
2 parents a964d54 + 621b2b3 commit efb2f3f
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 2 deletions.
75 changes: 75 additions & 0 deletions tests/data/telegram.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,80 @@
"timestamp": 1588071688.3739,
"updated_on": 1588071683.0,
"uuid": "31f3fdb5641680f47bd415f1299adc53f2d9c3f2"
},
{
"backend_name": "Telegram",
"backend_version": "0.11.1",
"category": "message",
"classified_fields_filtered": null,
"data": {
"message": {
"chat": {
"all_members_are_administrators": true,
"id": -375078074,
"title": "test api",
"type": "group"
},
"date": 1588071460,
"from": {
"first_name": "Animesh",
"id": 473180335,
"is_bot": false,
"language_code": "en",
"last_name": "Kumar",
"username": "animesh_username"
},
"message_id": 15,
"reply_to_message": {
"chat": {
"all_members_are_administrators": true,
"id": -375078074,
"title": "test api",
"type": "group"
},
"date": 1588071445,
"from": {
"first_name": "Animesh",
"id": 473180335,
"is_bot": false,
"language_code": "en",
"last_name": "Kumar",
"username": "animesh_username"
},
"message_id": 14,
"sticker": {
"emoji": "\ud83d\udc40",
"file_id": "CAACAgIAAxkBAAMPXqgNA1oj66ib0qG1ZA122OOQrV8AAikAAygPahS3xhSCjzmChhkE",
"file_size": 28338,
"file_unique_id": "AgADKQADKA9qFA",
"height": 512,
"is_animated": true,
"set_name": "Cat2O",
"thumb": {
"file_id": "AAMCAgADGQEAAw9eqA0DWiPrqJvSobVkDXbY45CtXwACKQADKA9qFLfGFIKPOYKGyJnMkS4AAwEAB20AA794AAIZBA",
"file_size": 5968,
"file_unique_id": "AQADyJnMkS4AA794AAI",
"height": 128,
"width": 128
},
"width": 512
}
},
"text": "test reply"
},
"update_id": 78683186
},
"offset": 78683186,
"origin": "https://telegram.org/owltestbot",
"perceval_version": "0.13.0",
"search_fields": {
"chat_id": -375078074,
"chat_name": "test api",
"item_id": "14"
},
"tag": "https://telegram.org/owltestbot",
"timestamp": 1588071463.96439,
"updated_on": 1588071460.0,
"uuid": "fcde9c211a41a5293dd72b2f806b5a7c2c8e0cb7"
}
]
28 changes: 26 additions & 2 deletions tests/test_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,32 @@ def test_items_to_raw(self):
"""Test whether JSON items are properly inserted into ES"""

result = self._test_items_to_raw()
self.assertEqual(result['items'], 9)
self.assertEqual(result['raw'], 9)
self.assertEqual(result['items'], 10)
self.assertEqual(result['raw'], 10)

def test_reply_to_message_text(self):
"""Test whether item has text field available"""

self._test_items_to_raw()
enrich_backend = self.connectors[self.connector][2]()

for item in self.items:
message = item['data']['message']
eitem = enrich_backend.get_rich_item(item)
if 'reply_to_message' in message:
if 'text' in message['reply_to_message']:
self.assertEqual(message['reply_to_message']['text'], eitem['reply_to_message'])

def test_reply_to_message_sticker(self):
"""Test whether item has sticker field available"""

self._test_items_to_raw()
enrich_backend = self.connectors[self.connector][2]()

item = self.items[9]
message = item['data']['message']
eitem = enrich_backend.get_rich_item(item)
self.assertEqual(message['reply_to_message']['sticker'], eitem['reply_to_message'])

def test_raw_to_enrich(self):
"""Test whether the raw index is properly enriched"""
Expand Down

0 comments on commit efb2f3f

Please sign in to comment.