Files
creator-hub/browser_gateway/test_event_details.py
T
rogee e50bed9ad8
douyin-release-gate / verify (push) Failing after 18m54s
feat: add account events and private message management
Add Douyin notification polling, event details, and manual multi-account private messaging.

Refine environment memory settings, account operations, login collection recovery, and message UI; update tests and documentation.
2026-10-07 10:23:05 +08:00

45 lines
2.2 KiB
Python

import unittest
from .platform.douyin import DouyinError, normalize_notice
class EventDetailsTests(unittest.TestCase):
def test_notification_preserves_user_profile_and_work_cover(self):
result = normalize_notice({'nid':'9007199254740993', 'comment': {
'from_user':{'uid':'456','nickname':'肉宝儿','sec_uid':'MS4wLjABAAAAprofile'},
'comment':{'cid':'789','text':'你好'},
'aweme':{'aweme_id':'987','aweme_type':0,'author':{'uid':'123'},
'video':{'cover':{'url_list':['https://p3.douyinpic.com/cover.jpg']}}},
}})
self.assertEqual(result['interactor_name'],'肉宝儿')
self.assertEqual(result['interactor_sec_uid'],'MS4wLjABAAAAprofile')
self.assertEqual(result['work_author_uid'],'123')
self.assertEqual(result['work_cover_url'],'https://p3.douyinpic.com/cover.jpg')
self.assertEqual(result['work_url'],'https://www.douyin.com/video/987')
def test_photo_and_comment_user_without_from_user(self):
result = normalize_notice({'nid':'1','comment':{
'comment':{'user':{'uid':'2','nickname':'作者','sec_uid':'MS4wLjABAAAAother'}},
'aweme':{'aweme_id':'3','aweme_type':68,'author':{'uid':'4'},
'images':[{'url_list':['https://p3.douyinpic.com/photo.jpg']}]},
}})
self.assertEqual(result['interactor_name'],'作者')
self.assertEqual(result['work_url'],'https://www.douyin.com/note/3')
self.assertEqual(result['work_cover_url'],'https://p3.douyinpic.com/photo.jpg')
def test_unknown_or_merged_users_do_not_get_fabricated_profiles(self):
result = normalize_notice({'nid':'4','follow':{'from_user':[{'uid':'2'},{'uid':'3'}]}})
self.assertEqual(result['interactor_name'],'')
self.assertEqual(result['interactor_sec_uid'],'')
self.assertEqual(result['work_cover_url'],'')
self.assertEqual(result['work_url'],'')
def test_invalid_profile_fields_fail_clearly(self):
for field in ('nickname','sec_uid'):
with self.subTest(field=field), self.assertRaises(DouyinError):
normalize_notice({'nid':'5','follow':{'from_user':{'uid':'2',field:123}}})
if __name__ == '__main__':
unittest.main()