def test_user_receives(self): user = utils.create_user() pn = Actions.daily_free_stickers(user, 5) ex = expander.get_expander(pn)() recipients = ex.decide_recipients(pn) self.assertEqual(len(recipients), 1) self.assertIn(user, recipients)
def action_recipients(action_name, *args, **kwargs): pn = getattr(Actions, action_name)(*args) new_expander = expander.get_expander(pn)() notifications = new_expander.expand(pn) channel = kwargs.get("channel") if channel: notifications = [n for n in notifications if n.channel == channel] return [n.recipient for n in notifications if n.action == action_name]
def action_recipients(action_name, *args, **kwargs): pn = getattr(Actions, action_name)(*args) new_expander = expander.get_expander(pn)() notifications = new_expander.expand(pn) channel = kwargs.get('channel') if channel: notifications = [n for n in notifications if n.channel == channel] return [n.recipient for n in notifications if n.action == action_name]
def test_op_author_expander_notifies_author(self): author = utils.create_user() comment = utils.create_comment() comment.author = author comment.save() self.assertEqual(comment.thread.op.author, author) another_user = utils.create_user() pn = Actions.replied(another_user, comment) replied_expander = expander.get_expander(pn)() notifications = replied_expander.expand(pn) recipients = [n.recipient for n in notifications] #self.assertEqual(len(recipients), 1) self.assertIn(author, recipients)
def test_notifies_author(self): author = utils.create_user() comment = utils.create_comment() comment.author = author comment.save() another_user = utils.create_user() comment_sticker = CommentSticker(comment=comment, type_id=stickers.get("num1").type_id, timestamp=time.time(), ip="127.0.0.1", user=another_user) pn = Actions.stickered(another_user, comment_sticker) ex = expander.get_expander(pn)() recipients = ex.decide_recipients(pn) self.assertEqual(len(recipients), 1) self.assertIn(author, recipients)