def test_al_hacer_post_para_inciar_una_tarea(self): user= User.objects.create(username="******",password="******") factory = RequestFactory() request = factory.post("/yourtasks") t = TaskFactory(user=user, started=True) request.user = user request.POST["task_selected"] = t.id request.POST["choisebuttom"] = "Start" yourtasks(request) tasks_started = Task.objects.filter(started=True).count() self.assertEqual(tasks_started,1)
def test_al_hacer_get_en_enlace_de_todas_las_tareas_muestra_esas_tareas(self): user = User.objects.create(username="******", password="******") project = ProjectFactory() t1 = TaskFactory(user=user, project=project) t1.start() t1.stop() other_month = datetime.now() - timedelta(days=32) t2 = TaskFactory(user=user,project=project) t2.current_timer = TimerFactory(task=t2, initial_time=other_month) t2.stop() t3 = TaskFactory(user=user,project=project) t3.current_timer = TimerFactory(task=t3, initial_time=other_month, final_time=other_month) factory = RequestFactory() request = factory.get("/yourtasks/") request.user = user result = yourtasks(request) self.assertIn(t1.name,result.content) self.assertIn(t2.name,result.content) self.assertIn(t3.name,result.content) self.assertEqual(result.status_code,200)
def test_al_hacer_get_en_yourtask_se_obtienen_dos_enlaces_de_tareas_actuales_y_antiguas(self): user = User.objects.create(username="******", password="******") factory = RequestFactory() request = factory.get("/yourtasks") request.user = user result = yourtasks(request) self.assertIn('<a href="/yourtasks/current_month">Current month</a>',result.content) self.assertIn('<a href="/yourtasks/all_tasks">All Tasks</a>',result.content) self.assertEqual(result.status_code,200)