Example #1
0
def test_delete_task(resource):
    user_id = resource
    task_to_del = TaskRepo.add_task(description="This is a task", user=user_id)
    TaskRepo.add_task(description="This is another task", user=user_id)
    assert len(TaskRepo.get_all_tasks()) == 2
    assert TaskRepo.delete_task(task_to_del["id"], user_id) == True
    remaining_tasks = TaskRepo.get_all_tasks()
    assert len(remaining_tasks) == 1
    assert remaining_tasks[0]["description"] == "This is another task"
Example #2
0
def test_toggle_task_todo_to_done(resource):
    user_id = resource
    TaskRepo.add_task(description="This is a task", user=user_id)
    tasks = TaskRepo.get_all_tasks()
    assert len(tasks) == 1
    assert tasks[0]["description"] == "This is a task"
    assert tasks[0]["status"] == "todo"
    assert TaskRepo.toggle_task(str(tasks[0]["id"])) == True
    tasks = TaskRepo.get_all_tasks()
    assert len(tasks) == 1
    assert tasks[0]["description"] == "This is a task"
    assert tasks[0]["status"] == "done"
Example #3
0
def test_store_task(resource):
    user_id = resource
    TaskRepo.add_task(description="This is a task", user=user_id)
    tasks = TaskRepo.get_all_tasks()
    assert len(tasks) == 1
    assert tasks[0]["description"] == "This is a task"
    assert tasks[0]["status"] == "todo"
Example #4
0
def task_get():
    uid = current_user.get_obj_id()
    user_tasks = TaskRepo.get_all_tasks(user=uid)
    res = {}
    res["success"] = True
    res["data"] = user_tasks
    return json.dumps(res)
Example #5
0
def test_task_to_project(resource):
    user_id = resource
    task = TaskRepo.add_task(description="Thing", user=user_id)
    project = TaskRepo.task_to_project(task["id"], user_id)
    # No more tasks
    assert len(TaskRepo.get_all_tasks()) == 0
    # Project used to be the task
    assert project is not None
    assert project["description"] == "Thing"
Example #6
0
def test_store_project(resource):
    user_id = resource
    TaskRepo.add_task(description="Task1", user=user_id)
    TaskRepo.add_task(description="Task2", user=user_id)
    tasks = list(map(lambda t: t["id"], TaskRepo.get_all_tasks()))
    ProjectRepo.add_project(description="ProjectA", tasks=tasks, user=user_id)
    projects = ProjectRepo.get_all_projects()
    assert len(projects) == 1
    assert projects[0]["description"] == "ProjectA"
    assert len(projects[0]["tasks"]) == 2
    assert projects[0]["tasks"][0]["id"] in tasks
    assert projects[0]["tasks"][1]["id"] in tasks