def main(): habitapi = HabitAPI("<foo>", "<bar>") task_warrior = TaskWarrior(data_location='~/.task', create=False) task_warrior.config.update({ "uda.habitrpg-id.type": "string", "uda.habitrpg-id.label": "HabitRPG ID" }) #get data from habitrpg todos = habitapi.todos() #dailies = habitapi.dailies() #get local data from taskwarrior tw_todos = task_warrior.tasks.filter(tags__contains=["habitrpg"]) print "== Taskwarriror Todos ===\n" for tw_todo in tw_todos: print tw_todo print "=========================\n" print "=== HabitRPG Todos ===\n" for habit_todo in todos: remote_name = habit_todo[u'text'] #print "%s (%s)" % (remote_name,type(remote_name)) local = tw_todos.filter(description__contains=remote_name) if local: print local # if local: # print "Task %s already exists locally, checking for a habitrpg ID ..." # print type(local) # else: # print "Task %s does not exist locally creating it ..." % remote_name print "=======================\n"
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
def __init__(self): # Determine defaults default_rc = vim.vars.get('taskwiki_taskrc_location') or '~/.taskrc' default_data = vim.vars.get('taskwiki_data_location') or '~/.task' default_kwargs = dict( data_location=default_data, taskrc_location=default_rc, ) # Setup the store of TaskWarrior objects self.warriors = {'default': TaskWarrior(**default_kwargs)} extra_warrior_defs = vim.vars.get('taskwiki_extra_warriors', {}) for key in extra_warrior_defs.keys(): current_kwargs = default_kwargs.copy() current_kwargs.update(extra_warrior_defs[key]) self.warriors[key] = TaskWarrior(**current_kwargs) # Make sure context is not respected in any TaskWarrior for tw in self.warriors.values(): tw.config.update({'context': ''})
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
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
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
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()
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()