Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_calcular_costo_para_obtener_el_valor_total_por_una_tarea_con_todos_sus_tiempos(self):
        user = User.objects.create(username="******",password="******")
        
        t1 = TaskFactory(user=user)

        t1.current_timer = TimerFactory(task=t1, initial_time=datetime(2013, 10, 31, 17, 56, 1, 0),
                final_time=datetime(2013, 10, 31, 18, 56, 1, 0))
       
        t1.current_timer = TimerFactory(task=t1, initial_time=datetime(2013, 10, 31, 18, 56, 1, 0),
                final_time=datetime(2013, 10, 31, 19, 56, 1, 0))
        
        result = t1.calculate_cost()
        self.assertEqual(result,8000)
Ejemplo n.º 3
0
    def test_calcular_tiempo_para_devolver_el_tiempo_total_de_una_tarea(self):
        user = User.objects.create(username="******",password="******")

        t1 = TaskFactory(name="Task1",user=user)

        t1.current_timer = TimerFactory(task=t1, initial_time=datetime(2013, 10, 31, 17, 56, 1, 0),
                final_time=datetime(2013, 10, 31, 18, 56, 1, 0))
        
        t1.current_timer = TimerFactory(task=t1, initial_time=datetime(2013, 10, 31, 18, 56, 1, 0),
                final_time=datetime(2013, 10, 31, 19, 56, 1, 0))

        result = t1.calculate_time()
        self.assertEqual(result.hours, 2)
Ejemplo n.º 4
0
    def test_current_month_tasks_deberia_retortar_solo_las_tareas_que_tienen_timers_en_el_mes_actual(self):
        user = User.objects.create(username="******",password="******")

        last_month = datetime.today() - timedelta(days=32)

        t1 = TaskFactory(user=user)
        t1.current_timer = TimerFactory(task=t1, initial_time=last_month, final_time=last_month)

        t2 = TaskFactory(user=user)
        t2.current_timer = TimerFactory(task=t2, initial_time=last_month, final_time=datetime.today())

        t3 = TaskFactory(user=user)
        t3.current_timer = TimerFactory(task=t3, initial_time=datetime.today(), final_time=datetime.today())

        result = Task.objects.current_month_tasks()
        
        self.assertEqual(set(result), set([t2, t3]))
Ejemplo n.º 5
0
    def test_pausar_una_tarea_para_desvicularle_el_cronometro_temporal_y_asignarle_tiempo_final(self):
        user = User.objects.create(username="******",password="******")

        t1 = TaskFactory(user=user)
        t1.current_timer = TimerFactory(task=t1, final_time=datetime(2013, 10, 31, 17, 56, 1, 0))
        
        time = t1.current_timer
        self.assertEqual(time.final_time.second, 1)
        
        t1.current_timer = None
        t1.save()

        timer_in_task = t1.current_timer
        self.assertEqual(timer_in_task, None)
        
        timers= t1.timer_set.all().count()
        self.assertEqual(timers, 2)
Ejemplo n.º 6
0
    def test_iniciar_una_tarea_para_crearle_un_cronometro_temporal_y_darle_su_tiempo_de_inicio(self):
        user = User.objects.create(username="******",password="******")
        
        t1 = TaskFactory(user=user)
        t1.current_timer = TimerFactory(task=t1, initial_time=datetime(2013, 10, 31, 17, 56, 1, 0))

        timers = t1.timer_set.all().count()
        time = t1.current_timer

        self.assertEqual(timers, 2)
        self.assertEqual(time.initial_time.second, 1)