diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 9914eb3830..4e8d0205a0 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -79,6 +79,7 @@ from zerver.lib.actions import ( do_update_outgoing_webhook_service, do_update_pointer, do_update_user_presence, + get_typing_user_profiles, log_event, lookup_default_stream_groups, notify_attachment_update, @@ -912,6 +913,25 @@ class EventsRegisterTest(ZulipTestCase): error = schema_checker('events[0]', events[0]) self.assert_on_error(error) + def test_get_typing_user_profiles(self) -> None: + """ + Make sure we properly assert failures for recipient types that should not + get typing... notifications. + """ + + sender_profile = self.example_user('cordelia') + stream = get_stream('Rome', sender_profile.realm) + + # Test stream + with self.assertRaisesRegex(ValueError, 'not supported for streams'): + recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM) + get_typing_user_profiles(recipient, sender_profile.id) + + # Test some other recipient type + with self.assertRaisesRegex(ValueError, 'Bad recipient type'): + recipient = Recipient(type=999) # invalid type + get_typing_user_profiles(recipient, sender_profile.id) + def test_custom_profile_fields_events(self) -> None: schema_checker = self.check_events_dict([ ('type', equals('custom_profile_fields')),