def test_message_notifier(user: User, admin: User, mocker: MockFixture): """Should run a notifier on save.""" mock = mocker.patch("communication.models.Message.notifier") message = Message() message.recipient = user message.sender = admin message.subject = "subject" message.body = "body" message.save() assert mock.call_count == 1
def test_notify_new_message( user: User, admin: User, mailoutbox: List[EmailMultiAlternatives], ): """Should notify about a new message.""" message = Message() message.recipient = user message.sender = admin message.subject = "subject" message.body = "body" notify_new_message(message) assert len(mailoutbox) == 1 assert user.email in mailoutbox[0].recipients() notify_new_message(message) assert len(mailoutbox) == 2