Пример #1
0
 def test_send_again(self):
     count_messages_before_send_again = len(
         message_history.MessageHistory.objects.all())
     message = message_history.MessageHistory.objects.get(id=1)
     receiver = create_receiver(message.receiver_id,
                                '*****@*****.**', 'fr-BE')
     message = send_again(receiver, message.id)
     self.assertIsNotNone(message,
                          'Message history should have been sent again')
     count_messages_after_send_again = len(
         message_history.MessageHistory.objects.all())
     self.assertTrue(
         count_messages_after_send_again == count_messages_before_send_again
         + 1, 'It should be {} messges in messages history'.format(
             count_messages_before_send_again + 1))
Пример #2
0
def send_again(message_history_id):
    """
    send a message from message history again
    :param message_history_id The id of the message history to send again
    :return the sent message

    TO-DO : correction of send_message in osis-common to get the associated receiver , based on id and receiver model

    """
    message_history = message_history_mdl.find_by_id(message_history_id)
    person = person_mdl.find_by_id(message_history.receiver_id)
    if person:
        receiver = message_config.create_receiver(person.id, person.email, person.language)
        return message_service.send_again(receiver, message_history_id)
    else:
        return _('no_receiver_error')