Пример #1
0
 def todo(self):
     nextTask = self.prompt(self.tw.tasks.pending().filter('+todo'))
     if isinstance(nextTask, str):
         task = Task(self.tw, description=nextTask, tags=['todo'])
         task.save()
     else:
         nextTask['tags'].remove('todo')
         nextTask.save()
         self.change(nextTask)
Пример #2
0
 def test_add(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         assert len(tw.tasks.filter('Arena:foo')) == 1
Пример #3
0
 def test_add(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         assert len(tw.tasks.filter('Arena:foo')) == 1
Пример #4
0
 def test_local(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         result = self.runner.invoke(cli, cmd + ['local', 'foo', 'dishes'])
         assert 'dishes' in result.output
Пример #5
0
 def test_local(self):
     with self.runner.isolated_filesystem():
         dloc = os.getcwd() + '/local'
         tw = TaskWarrior(dloc)
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         result = self.runner.invoke(cli, cmd + ['local', 'foo', 'dishes'])
         assert 'dishes' in result.output
Пример #6
0
 def test_sync(self):
     with self.runner.isolated_filesystem():
         cwd = os.getcwd()
         dloc = cwd + '/local'
         dremote = cwd + '/remote'
         tw_local = TaskWarrior(dloc)
         tw_remote = TaskWarrior(dremote)
         t = Task(tw_local)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         result = self.runner.invoke(cli, cmd + ['sync', 'foo'], input='a\n')
         assert len(tw_remote.tasks.filter()) == 1
Пример #7
0
 def test_remote(self):
     with self.runner.isolated_filesystem():
         self.runner.invoke(cli, cmd_dummy_arena)
         dloc = os.getcwd() + '/remote'
         tw = TaskWarrior(dloc)
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t['Arena'] = 'foo'
         t['ArenaTaskID'] = '1'
         t.save()
         result = self.runner.invoke(cli, cmd + ['remote', 'foo', 'dishes'])
         assert 'dishes' in result.output
Пример #8
0
 def test_remote(self):
     with self.runner.isolated_filesystem():
         self.runner.invoke(cli, cmd_dummy_arena)
         dloc = os.getcwd() + '/remote'
         tw = TaskWarrior(dloc)
         for uda in uda_config_list:
             tw.config.update({uda[0]: uda[1]})
         t = Task(tw)
         description = 'do dishes'
         t['description'] = description
         t['Arena'] = 'foo'
         t['ArenaTaskID'] = '1'
         t.save()
         result = self.runner.invoke(cli, cmd + ['remote', 'foo', 'dishes'])
         assert 'dishes' in result.output
Пример #9
0
    def new_task(self):
        """
        Create a new empty task

        :return: a empty task
        :rtype: Taskwarrior task object
        """
        return Task(self.taskwarrior_client)
Пример #10
0
 def test_sync(self):
     with self.runner.isolated_filesystem():
         cwd = os.getcwd()
         dloc = cwd + '/local'
         dremote = cwd + '/remote'
         tw_local = TaskWarrior(dloc)
         tw_remote = TaskWarrior(dremote)
         t = Task(tw_local)
         description = 'do dishes'
         t['description'] = description
         t.save()
         self.runner.invoke(cli, cmd_dummy_arena)
         self.runner.invoke(cli, cmd + ['add', 'foo', description])
         result = self.runner.invoke(cli,
                                     cmd + ['sync', 'foo'],
                                     input='a\n')
         assert len(tw_remote.tasks.filter()) == 1
Пример #11
0
    def task(self):
        # New task object accessed second or later time
        if self.__unsaved_task is not None:
            return self.__unsaved_task

        # Return the corresponding task if alrady set
        # Else try to load it or create a new one
        if self.uuid:
            try:
                return self.cache[self.uuid]
            except Task.DoesNotExist:
                # Task with stale uuid, recreate
                self.__unsaved_task = Task(self.tw)
                # If task cannot be loaded, we need to remove the UUID
                vim.command('echom "UUID not found: %s,'
                            'will be replaced if saved"' % self.uuid)
                self.uuid = None
        else:
            # New task object accessed first time
            self.__unsaved_task = Task(self.tw)

        return self.__unsaved_task
Пример #12
0
    def generate_data(self):
        super(MultipleSourceTest, self).generate_data()

        self.extra_dir = tempfile.mkdtemp(dir='/tmp/')

        self.extra_tw = TaskWarrior(
            data_location=self.extra_dir,
            taskrc_location='/'
        )

        extra_tasks = [Task(self.extra_tw, **task_kwargs)
                      for task_kwargs in self.extra_tasks]

        self.extra_tasks = extra_tasks
        for task in self.extra_tasks:
            task.save()
Пример #13
0
    def generate_data(self):
        self.dir = tempfile.mkdtemp(dir='/tmp/')

        # Create an actual taskrc file where we can write later
        self.taskrc_path = os.path.join(self.dir, "taskrc")
        with open(self.taskrc_path, 'w') as f:
            f.write("#testing taskrc\n")

        self.tw = TaskWarrior(
            data_location=self.dir,
            taskrc_location=self.taskrc_path
        )

        new_tasks = [Task(self.tw, **task_kwargs)
                     for task_kwargs in self.tasks]

        self.tasks = new_tasks
        for task in self.tasks:
            task.save()
Пример #14
0
def download_trello_card(project_name, list_name, trello_card, task_warrior,
                         doing_list_name, done_list_name):
    """
    Download all contens of trello card creating new Task Warrior task

    :project_name: the name of project where the card is stored
    :list_name: the name of list where the card is stored
    :trello_card: a Trello Card object
    :task_warrior: Task Warrior object
    :doing_list_name: name of doing list to set task active
    :done_list_name: name of done list to set task done
    """
    new_tw_task = Task(task_warrior)
    new_tw_task['project'] = project_name
    new_tw_task['description'] = trello_card.name
    if trello_card.due_date:
        new_tw_task['due'] = trello_card.due_date
    new_tw_task['trelloid'] = trello_card.id
    new_tw_task['trellolistname'] = list_name
    new_tw_task.save()
    if list_name == doing_list_name:
        new_tw_task.start()
    if list_name == done_list_name:
        new_tw_task.done()
Пример #15
0
def download_trello_card(project_name, list_name, trello_card, task_warrior, doing_list_name, done_list_name):
    """Download all contents of Trello card, creating new Taskwarrior task

    :project_name: the name of project where the card is stored
    :list_name: the name of list where the card is stored
    :trello_card: a Trello Card object
    :task_warrior: Taskwarrior object
    :doing_list_name: name of doing list to set task active
    :done_list_name: name of done list to set task done
    """
    new_tw_task = Task(task_warrior)
    new_tw_task['project'] = project_name
    new_tw_task['description'] = trello_card.name
    if trello_card.due_date:
        new_tw_task['due'] = trello_card.due_date
    new_tw_task['trelloid'] = trello_card.id
    new_tw_task['trellolistname'] = list_name
    new_tw_task.save()
    if list_name == doing_list_name:
        new_tw_task.start()
    if list_name == done_list_name:
        new_tw_task.done()
Пример #16
0
    def pause(self, restart=True):
        active = self.current()
        if not active: return

        if active['description'] == self.PAUSED:
            prev = self.tw.tasks.pending().get(tags__contains = [self.PAUSED])
            active.stop()
            prev['tags'].remove(self.PAUSED)
            prev.save()

            if restart:
                prev.start()
        else:
            pause_task = self.tw.tasks.pending().filter(description = self.PAUSED)
            if not pause_task:
                pause_task = Task(self.tw, description=self.PAUSED)
                pause_task.save()
            else:
                pause_task = pause_task.get()

            active.stop()
            active['tags'].add(self.PAUSED)
            active.save()
            pause_task.start()