def test_build_zerver_message(self) -> None: zerver_usermessage = [] # type: List[Dict[str, Any]] usermessage_id_count = 0 usermessage_id_list = [3, 7, 8, 11] zerver_subscription = [{'recipient': 2, 'user_profile': 7}, {'recipient': 4, 'user_profile': 12}, {'recipient': 2, 'user_profile': 16}, {'recipient': 2, 'user_profile': 15}, {'recipient': 2, 'user_profile': 3}] recipient_id = 2 mentioned_users_id = [12, 3, 16] message_id = 9 test_zerver_usermessage, test_usermessage_id = build_zerver_usermessage(zerver_usermessage, usermessage_id_count, usermessage_id_list, zerver_subscription, recipient_id, mentioned_users_id, message_id) self.assertEqual(test_usermessage_id, 4) self.assertEqual(test_zerver_usermessage[0]['flags_mask'], 1) self.assertEqual(test_zerver_usermessage[0]['id'], 3) self.assertEqual(test_zerver_usermessage[0]['message'], message_id) self.assertEqual(test_zerver_usermessage[1]['user_profile'], zerver_subscription[2]['user_profile']) self.assertEqual(test_zerver_usermessage[1]['flags_mask'], 9) self.assertEqual(test_zerver_usermessage[3]['id'], 11) self.assertEqual(test_zerver_usermessage[3]['message'], message_id)
def test_build_zerver_message(self) -> None: zerver_usermessage = [] # type: List[Dict[str, Any]] usermessage_id_count = 0 usermessage_id_list = [3, 7, 8, 11] zerver_subscription = [{'recipient': 2, 'user_profile': 7}, {'recipient': 4, 'user_profile': 12}, {'recipient': 2, 'user_profile': 16}, {'recipient': 2, 'user_profile': 15}, {'recipient': 2, 'user_profile': 3}] recipient_id = 2 mentioned_users_id = [12, 3, 16] message_id = 9 test_usermessage_id = build_zerver_usermessage(zerver_usermessage, usermessage_id_count, usermessage_id_list, zerver_subscription, recipient_id, mentioned_users_id, message_id) self.assertEqual(test_usermessage_id, 4) self.assertEqual(zerver_usermessage[0]['flags_mask'], 1) self.assertEqual(zerver_usermessage[0]['id'], 3) self.assertEqual(zerver_usermessage[0]['message'], message_id) self.assertEqual(zerver_usermessage[1]['user_profile'], zerver_subscription[2]['user_profile']) self.assertEqual(zerver_usermessage[1]['flags_mask'], 9) self.assertEqual(zerver_usermessage[3]['id'], 11) self.assertEqual(zerver_usermessage[3]['message'], message_id)