How to use the tasklib.task.Task.CompletedTask function in tasklib

To help you get started, we’ve selected a few tasklib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robgolding / tasklib / tasklib / tests.py View on Github external
def test_start_completed_task(self):
        t = Task(self.tw, description='test task')
        t.save()
        t.done()

        self.assertRaises(Task.CompletedTask, t.start)
github scottkosty / vit / vit / task.py View on Github external
def task_start_stop(self, uuid):
        task = self.get_task(uuid)
        if task:
            try:
                task.stop() if task.active else task.start()
                return True, task
            except (Task.CompletedTask, Task.DeletedTask, Task.ActiveTask, Task.InactiveTask) as e:
                return False, e
        return False, None
github robgolding / tasklib / tasklib / task.py View on Github external
def done(self):
        if not self.saved:
            raise Task.NotSaved(
                'Task needs to be saved before it can be completed',
            )

        # Refresh, and raise exception if task is already completed/deleted
        self.refresh(only_fields=['status'])

        if self.completed:
            raise Task.CompletedTask('Cannot complete a completed task')
        elif self.deleted:
            raise Task.DeletedTask('Deleted task cannot be completed')

        self.backend.complete_task(self)

        # Refresh the status again, so that we have updated info stored
        self.refresh(only_fields=['status', 'start', 'end'])
github robgolding / tasklib / tasklib / task.py View on Github external
def start(self):
        if not self.saved:
            raise Task.NotSaved(
                'Task needs to be saved before it can be started',
            )

        # Refresh, and raise exception if task is already completed/deleted
        self.refresh(only_fields=['status'])

        if self.completed:
            raise Task.CompletedTask('Cannot start a completed task')
        elif self.deleted:
            raise Task.DeletedTask('Deleted task cannot be started')
        elif self.active:
            raise Task.ActiveTask('Task is already active')

        self.backend.start_task(self)

        # Refresh the status again, so that we have updated info stored
        self.refresh(only_fields=['status', 'start'])