Ejemplo n.º 1
0
 def test_remove_task(self):
     """Should remove and specific task"""
     task_redis_id = self.rd.keys("task:*")[0]
     Task.remove(task_redis_id.replace('task:', ''))
     tasks = self.rd.keys("task:*")
     self.assertEqual(len(tasks), len(TASK_FIXTURES) - 1)
     self.assertFalse(self.rd.keys(task_redis_id))
Ejemplo n.º 2
0
def edit_task_title():
    next = request.args.get('next', '/')
    Task.edit_field(current_user.get_id(),
                    request.form['task_id'],
                    'title',
                    request.form['title'])
    return redirect(next)
Ejemplo n.º 3
0
def edit_task_status():
    next = request.args.get('next', '/')
    if request.form['status'] in ['True', 'true', 'TRUE']:
        status = 'completed'
    else:
        status = 'uncompleted'
    Task.edit_field(current_user.get_id(), request.form['task_id'],
                    'status', status)
    return redirect(next)
Ejemplo n.º 4
0
 def test_edit_field(self):
     """Should change the value of a specific field"""
     task_redis_id = self.rd.keys("task:*")[0]
     old_task_data = self.rd.hgetall(task_redis_id)
     task_id = task_redis_id.replace('task:', '')
     Task.edit_field(task_id, 'title', 'New title')
     Task.edit_field(task_id, 'status', 'completed')
     new_task_data = self.rd.hgetall(task_redis_id)
     self.assertNotEqual(old_task_data['title'], 'New title')
     self.assertNotEqual(old_task_data['status'], 'completed')
     self.assertEqual('New title', new_task_data['title'])
     self.assertEqual('completed', new_task_data['status'])
Ejemplo n.º 5
0
 def test_get_all_tasks(self):
     """Should get all the tasks for the given username"""
     tasks = Task.get_tasks(USER['username'])
     self.assertEqual(len(tasks), len(TASK_FIXTURES))
     for task in tasks:
         self.assertTrue(task['title'] in TASK_FIXTURES)
         self.assertEqual(task['status'], 'uncompleted')
Ejemplo n.º 6
0
def day_tasks():
    day_tasks = {}
    tasks = Task.get_tasks(current_user.get_id())
    for task in tasks:
        day_tasks.setdefault(task['timestamp'], []).append(task)
    return render_template(
        'tasks_day.html',
        day_tasks=day_tasks
    )
Ejemplo n.º 7
0
 def setUp(self):
     super(TaskTestCase, self).setUp()
     for task in TASK_FIXTURES:
         t = Task(USER['username'], task)
         t.save()
Ejemplo n.º 8
0
def delete_task():
    next = request.args.get('next', '/')
    Task.remove(request.form['task_id'])
    return redirect(next)
Ejemplo n.º 9
0
def create_task():
    next = request.args.get('next', '/')
    t = Task(current_user.get_id(), request.form['task'])
    t.save()
    return redirect(next)
Ejemplo n.º 10
0
def uncompleted_tasks():
    return render_template(
        'tasks_completed.html',
        uncompleted_tasks=Task.get_tasks(current_user.get_id(),
                                         status='uncompleted')
    )
Ejemplo n.º 11
0
def week_tasks():
    week_tasks = Task.get_tasks(current_user.get_id())
    return render_template(
        'tasks_week.html',
        week_tasks=week_tasks
    )