def create_message_commands_task(msg_id): """ Runs :func:`kiki.utils.routing.create_message_commands` and immediately passes the resulting :class:`kiki.models.ListCommand`\ s on to the appropriate tasks. """ try: msg = Message.objects.get(pk=msg_id, status__in=[Message.UNPROCESSED, Message.FAILED]) except Message.DoesNotExist: return list_cmds = create_message_commands(msg) for list_cmd in list_cmds: COMMAND_TASKS[list_cmd.command].delay(list_cmd.pk)
def test_create_message_commands(self): message = Message.objects.get(pk=3) list_cmds = create_message_commands(message) self.assertGreater(len(list_cmds), 0) self.assertIsInstance(list_cmds[0], ListCommand)