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'.
This commit is contained in:
sahil839 2021-01-08 01:03:02 +05:30 committed by Tim Abbott
parent 81ae29d461
commit 15e74a637c
1 changed files with 10 additions and 0 deletions

View File

@ -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(