mirror of https://github.com/zulip/zulip.git
tests: Avoid Union type to verify stream names.
There's also no need to fetch a full Stream object when the thing being verified is just that the display_recipient field matches the stream name.
This commit is contained in:
parent
233486f7b3
commit
6ff7c17f82
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.utils.timezone import now as timezone_now
|
from django.utils.timezone import now as timezone_now
|
||||||
|
@ -490,12 +490,8 @@ class TestMessageForIdsDisplayRecipientFetching(ZulipTestCase):
|
||||||
def _verify_display_recipient(
|
def _verify_display_recipient(
|
||||||
self,
|
self,
|
||||||
display_recipient: DisplayRecipientT,
|
display_recipient: DisplayRecipientT,
|
||||||
expected_recipient_objects: Union[Stream, List[UserProfile]],
|
expected_recipient_objects: List[UserProfile],
|
||||||
) -> None:
|
) -> None:
|
||||||
if isinstance(expected_recipient_objects, Stream):
|
|
||||||
self.assertEqual(display_recipient, expected_recipient_objects.name)
|
|
||||||
|
|
||||||
else:
|
|
||||||
for user_profile in expected_recipient_objects:
|
for user_profile in expected_recipient_objects:
|
||||||
recipient_dict: UserDisplayRecipient = {
|
recipient_dict: UserDisplayRecipient = {
|
||||||
"email": user_profile.email,
|
"email": user_profile.email,
|
||||||
|
@ -544,12 +540,8 @@ class TestMessageForIdsDisplayRecipientFetching(ZulipTestCase):
|
||||||
allow_edit_history=False,
|
allow_edit_history=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._verify_display_recipient(
|
self.assertEqual(messages[0]["display_recipient"], "Verona")
|
||||||
messages[0]["display_recipient"], get_stream("Verona", cordelia.realm)
|
self.assertEqual(messages[1]["display_recipient"], "Denmark")
|
||||||
)
|
|
||||||
self._verify_display_recipient(
|
|
||||||
messages[1]["display_recipient"], get_stream("Denmark", cordelia.realm)
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_display_recipient_huddle(self) -> None:
|
def test_display_recipient_huddle(self) -> None:
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
|
@ -607,13 +599,9 @@ class TestMessageForIdsDisplayRecipientFetching(ZulipTestCase):
|
||||||
self._verify_display_recipient(
|
self._verify_display_recipient(
|
||||||
messages[0]["display_recipient"], [hamlet, cordelia, othello]
|
messages[0]["display_recipient"], [hamlet, cordelia, othello]
|
||||||
)
|
)
|
||||||
self._verify_display_recipient(
|
self.assertEqual(messages[1]["display_recipient"], "Verona")
|
||||||
messages[1]["display_recipient"], get_stream("Verona", hamlet.realm)
|
|
||||||
)
|
|
||||||
self._verify_display_recipient(messages[2]["display_recipient"], [hamlet, cordelia])
|
self._verify_display_recipient(messages[2]["display_recipient"], [hamlet, cordelia])
|
||||||
self._verify_display_recipient(
|
self.assertEqual(messages[3]["display_recipient"], "Denmark")
|
||||||
messages[3]["display_recipient"], get_stream("Denmark", hamlet.realm)
|
|
||||||
)
|
|
||||||
self._verify_display_recipient(
|
self._verify_display_recipient(
|
||||||
messages[4]["display_recipient"], [hamlet, cordelia, othello, iago]
|
messages[4]["display_recipient"], [hamlet, cordelia, othello, iago]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue