tests: Use do_create_realm where possible.

Using do_create_realm should be preferred over manual creation where
possible, as it creates more realistic data.
This commit is contained in:
Mateusz Mandera
2021-03-08 13:22:43 +01:00
committed by Tim Abbott
parent bbe12a3967
commit d91d3a05b9
11 changed files with 65 additions and 26 deletions

View File

@@ -872,8 +872,13 @@ def generate_and_send_messages(
random.shuffle(dialog)
texts = itertools.cycle(dialog)
# We need to filter out streams from the analytics realm as we don't want to generate
# messages to its streams - and they might also have no subscribers, which would break
# our message generation mechanism below.
stream_ids = Stream.objects.filter(realm=get_realm("zulip")).values_list("id", flat=True)
recipient_streams: List[int] = [
klass.id for klass in Recipient.objects.filter(type=Recipient.STREAM)
recipient.id
for recipient in Recipient.objects.filter(type=Recipient.STREAM, type_id__in=stream_ids)
]
recipient_huddles: List[int] = [h.id for h in Recipient.objects.filter(type=Recipient.HUDDLE)]