From 15e74a637cd08147120ef08e093a1dc6f00afa44 Mon Sep 17 00:00:00 2001 From: sahil839 Date: Fri, 8 Jan 2021 01:03:02 +0530 Subject: [PATCH] tests: Check cases when full members and their bots can send messages. Currently there are only tests for verifying the error case and there are no tests to check the case where messages are sent successfully in 'STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS' stream. This commit adds tests for checking that full members and bots owned by them can send message successfully in streams with post policy as 'STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS'. --- zerver/tests/test_message_send.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 40b1ce6a9d..1daee9f72f 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -279,6 +279,16 @@ class MessagePOSTTest(ZulipTestCase): non_admin_owned_bot, stream_name, "New members cannot send to this stream." ) + non_admin_profile.date_joined = timezone_now() - datetime.timedelta(days=11) + non_admin_profile.save() + self.assertFalse(non_admin_profile.is_new_member) + + self._send_and_verify_message(non_admin_profile, stream_name) + # We again set bot owner here, as date_joined of non_admin_profile is changed. + non_admin_owned_bot.bot_owner = non_admin_profile + non_admin_owned_bot.save() + self._send_and_verify_message(non_admin_owned_bot, stream_name) + # Bots without owner (except cross realm bot) cannot send to STREAM_POST_POLICY_ADMINS_ONLY and # STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS streams bot_without_owner = do_create_user(