def grant_user_promotion(self, user, amount, message): account = self.account_manager.get_user_account(user) account.credit(amount, self.account_manager.get_promotions_account(), message) Notifications.get_notification_sender('promotion_granted').add( project_id=user, promotion_amount=amount, new_balance=account.balance(), message=message) Notifications.send_all_notifications()
def grant_user_promotion(self, user, amount, message): account = self.account_manager.get_user_account(user) account.credit( amount, self.account_manager.get_promotions_account(), message) Notifications.get_notification_sender('promotion_granted').add( project_id=user, promotion_amount=amount, new_balance=account.balance(), message=message) Notifications.send_all_notifications()
def test_notification_sending(self): Notifications.delete_all_notifications() number_recipients = 5 KeystoneClient.get_client().AndReturn( get_stub_keystone_client(number_recipients)) self.mox.ReplayAll() Notifications.get_notification_sender('low_balance').add( project_id=1, passed_limit=5, current_balance=4) Notifications.send_all_notifications() self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, LowBalanceNotificationSender.subject) self.assertEqual(mail.outbox[0].from_email, settings.DEFAULT_FROM_EMAIL) self.assertEqual(len(mail.outbox[0].to), number_recipients)
def handler(**kwargs): Notifications.get_notification_sender('low_balance').add(**kwargs)