Esempio n. 1
0
    def test_recipient_for_user_ids(self) -> None:
        hamlet = self.example_user('hamlet')
        othello = self.example_user('othello')
        cross_realm_bot = get_system_bot(settings.WELCOME_BOT)
        sender = self.example_user('iago')
        recipient_user_ids = [hamlet.id, othello.id, cross_realm_bot.id]

        result = recipient_for_user_ids(recipient_user_ids, sender)
        recipient = get_display_recipient(result)
        recipient_ids = [
            recipient[0]['id'],
            recipient[1]['id'],  # type: ignore
            recipient[2]['id'],
            recipient[3]['id']
        ]  # type: ignore

        expected_recipient_ids = [
            hamlet.id, othello.id, sender.id, cross_realm_bot.id
        ]
        self.assertEqual(set(recipient_ids), set(expected_recipient_ids))
Esempio n. 2
0
    def test_recipient_for_user_ids_non_existent_id(self) -> None:
        sender = self.example_user('iago')
        recipient_user_ids = [999]

        with self.assertRaisesRegex(ValidationError, 'Invalid user ID '):
            recipient_for_user_ids(recipient_user_ids, sender)