typing: Add assertions for Optional values.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-06 15:53:02 -04:00 committed by Tim Abbott
parent 7c62af0d73
commit 56855e0187
2 changed files with 3 additions and 0 deletions

View File

@ -3795,6 +3795,7 @@ def bot_owner_user_ids(user_profile: UserProfile) -> Set[int]:
and user_profile.default_events_register_stream.invite_only and user_profile.default_events_register_stream.invite_only
) )
if is_private_bot: if is_private_bot:
assert user_profile.bot_owner_id is not None
return {user_profile.bot_owner_id} return {user_profile.bot_owner_id}
else: else:
users = {user.id for user in user_profile.realm.get_human_admin_users()} users = {user.id for user in user_profile.realm.get_human_admin_users()}

View File

@ -403,6 +403,7 @@ class PreviewTestCase(ZulipTestCase):
# Verify the initial message doesn't have the embedded links rendered # Verify the initial message doesn't have the embedded links rendered
msg = Message.objects.select_related("sender").get(id=msg_id) msg = Message.objects.select_related("sender").get(id=msg_id)
assert msg.rendered_content is not None
self.assertNotIn(f'<a href="{url}" title="The Rock">The Rock</a>', msg.rendered_content) self.assertNotIn(f'<a href="{url}" title="The Rock">The Rock</a>', msg.rendered_content)
self.create_mock_response(url, relative_url=relative_url) self.create_mock_response(url, relative_url=relative_url)
@ -449,6 +450,7 @@ class PreviewTestCase(ZulipTestCase):
in info_logs.output[0] in info_logs.output[0]
) )
msg = Message.objects.select_related("sender").get(id=msg_id) msg = Message.objects.select_related("sender").get(id=msg_id)
assert msg.rendered_content is not None
# The content of the message has changed since the event for original_url has been created, # The content of the message has changed since the event for original_url has been created,
# it should not be rendered. Another, up-to-date event will have been sent (edited_url). # it should not be rendered. Another, up-to-date event will have been sent (edited_url).
self.assertNotIn( self.assertNotIn(