def test_welcome_mail_users(self): date_days_ago = lambda d,h=0: datetime.now() - timedelta(days=d, hours=h) User.objects.create(username='******', date_joined=date_days_ago(3), email='[email protected]') User.objects.create(username='******', date_joined=date_days_ago(1,12), email='[email protected]') drain_mail_queue() social_signals.daily_user_welcomes() mail = drain_mail_queue() # we're expecting a single mail to day1_5, # day3 is too old, bobby and others are too recent self.assertEqual(1, len(mail)) email = mail[0] self.assertEqual('[email protected]', email.to_addresses[0])
def test_welcome_mail_users(self): date_days_ago = lambda d, h=0: datetime.now() - timedelta(days=d, hours=h) User.objects.create(username='******', date_joined=date_days_ago(3), email='[email protected]') User.objects.create(username='******', date_joined=date_days_ago(1, 12), email='[email protected]') drain_mail_queue() social_signals.daily_user_welcomes() mail = drain_mail_queue() # we're expecting a single mail to day1_5, # day3 is too old, bobby and others are too recent self.assertEqual(1, len(mail)) email = mail[0] self.assertEqual('[email protected]', email.to_addresses[0])
def handle(self, *args, **opts): daily_user_welcomes()