mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
email_mirror: Add a test for sending to a private stream.
This verifies an important case. We still have an open bug for why in some production environments, the email_gateway_bot seems to not be tagged as an API super user (resulting in this code path not working).
This commit is contained in:
@@ -125,6 +125,31 @@ class TestStreamEmailMessagesSuccess(ZulipTestCase):
|
||||
self.assertEqual(get_display_recipient(message.recipient), stream.name)
|
||||
self.assertEqual(message.topic_name(), "(no topic)")
|
||||
|
||||
def test_receive_private_stream_email_messages_success(self) -> None:
|
||||
user_profile = self.example_user('hamlet')
|
||||
self.login(user_profile.email)
|
||||
self.make_stream("private_stream", invite_only=True)
|
||||
self.subscribe(user_profile, "private_stream")
|
||||
stream = get_stream("private_stream", user_profile.realm)
|
||||
|
||||
stream_to_address = encode_email_address(stream)
|
||||
|
||||
incoming_valid_message = MIMEText('TestStreamEmailMessages Body') # type: Any # https://github.com/python/typeshed/issues/275
|
||||
|
||||
incoming_valid_message['Subject'] = 'TestStreamEmailMessages Subject'
|
||||
incoming_valid_message['From'] = self.example_email('hamlet')
|
||||
incoming_valid_message['To'] = stream_to_address
|
||||
incoming_valid_message['Reply-to'] = self.example_email('othello')
|
||||
|
||||
process_message(incoming_valid_message)
|
||||
|
||||
# Hamlet is subscribed to this stream so should see the email message from Othello.
|
||||
message = most_recent_message(user_profile)
|
||||
|
||||
self.assertEqual(message.content, "TestStreamEmailMessages Body")
|
||||
self.assertEqual(get_display_recipient(message.recipient), stream.name)
|
||||
self.assertEqual(message.topic_name(), incoming_valid_message['Subject'])
|
||||
|
||||
class TestStreamEmailMessagesEmptyBody(ZulipTestCase):
|
||||
def test_receive_stream_email_messages_empty_body(self) -> None:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user