Files
zulip/zerver/tests/test_populate_db.py
Anders Kaseorg 365fe0b3d5 python: Sort imports with isort.
Fixes #2665.

Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.

Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start.  I expect this change will increase pressure for us to split
those files, which isn't a bad thing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00

22 lines
961 B
Python

from django.utils.timezone import timedelta as timezone_timedelta
from zerver.lib.test_classes import ZulipTestCase
from zilencer.management.commands.populate_db import choose_date_sent
class TestChoosePubDate(ZulipTestCase):
def test_choose_date_sent_large_tot_messages(self) -> None:
"""
Test for a bug that was present, where specifying a large amount of messages to generate
would cause each message to have date_sent set to timezone_now(), instead of the date_sents
being distributed across the span of several days.
"""
tot_messages = 1000000
datetimes_list = [
choose_date_sent(i, tot_messages, 1) for i in range(1, tot_messages, tot_messages // 100)
]
# Verify there is a meaningful difference between elements.
for i in range(1, len(datetimes_list)):
self.assertTrue(datetimes_list[i] - datetimes_list[i-1] > timezone_timedelta(minutes=5))