Пример #1
0
def recipients():
    # We use a cutoff of 48 hours ago, so that we don't retroactively send this to all existing users,
    # and so that there's a window large enought to ensure we don't miss a bunch of users if this ever breaks and
    # doesn't run for a day for whatever reason.
    cutoff = Services.time.today() - datetime.timedelta(days=2)
    return User.users_over_one_day_old(cutoff=cutoff).exclude(
        pk__in=WelcomeEmailRecipient.objects.all().values_list('recipient_id',
                                                               flat=True))
Пример #2
0
    def test_users_over_one_day_old(self):
        with override_service('time', FakeTimeProvider):
            beginning_count = User.users_over_one_day_old().count()
            def assert_count(count, cutoff=None):
                self.assertEqual(beginning_count + count, User.users_over_one_day_old(cutoff=cutoff).count())
            assert_count(0)

            [create_user() for _ in xrange(2)]
            assert_count(0)

            Services.time.step(60*60*48)
            assert_count(2)
            create_user()
            assert_count(2)
            Services.time.step(60*60)
            assert_count(2)
            assert_count(0, cutoff=(Services.time.today() - datetime.timedelta(days=1)))
Пример #3
0
    def test_users_over_one_day_old(self):
        with override_service('time', FakeTimeProvider):
            beginning_count = User.users_over_one_day_old().count()
            def assert_count(count, cutoff=None):
                self.assertEqual(beginning_count + count, User.users_over_one_day_old(cutoff=cutoff).count())
            assert_count(0)

            [create_user() for _ in xrange(2)]
            assert_count(0)

            Services.time.step(60*60*48)
            assert_count(2)
            create_user()
            assert_count(2)
            Services.time.step(60*60)
            assert_count(2)
            assert_count(0, cutoff=(Services.time.today() - datetime.timedelta(days=1)))
Пример #4
0
 def assert_count(count, cutoff=None):
     self.assertEqual(
         beginning_count + count,
         User.users_over_one_day_old(cutoff=cutoff).count())
def recipients():
    # We use a cutoff of 48 hours ago, so that we don't retroactively send this to all existing users,
    # and so that there's a window large enought to ensure we don't miss a bunch of users if this ever breaks and
    # doesn't run for a day for whatever reason.
    cutoff = Services.time.today() - datetime.timedelta(days=2)
    return User.users_over_one_day_old(cutoff=cutoff).exclude(pk__in=WelcomeEmailRecipient.objects.all().values_list('recipient_id', flat=True))
Пример #6
0
 def assert_count(count, cutoff=None):
     self.assertEqual(beginning_count + count, User.users_over_one_day_old(cutoff=cutoff).count())