Beispiel #1
0
 def test_returns_user_tasks(self):
     first_task = TaskFactory()
     second_task = TaskFactory()
     user_id = 10
     first_task.user_id = user_id
     second_task.user_id = user_id
     self.task_storage.create(first_task)
     self.task_storage.create(second_task)
     tasks = self.task_storage.user_tasks(user_id)
     self.assertEqual(len(tasks), 2)
Beispiel #2
0
 def test_processes_task_plans(self):
     user_id = 10
     repeated_task = TaskFactory()
     repeated_task.status = Status.TEMPLATE.value
     repeated_task.user_id = user_id
     task_id = self.task_storage.create(repeated_task).id
     before_tasks_count = len(self.task_storage.user_tasks(user_id))
     interval = 300
     big_interval = interval * 10
     last_created_at = datetime.datetime.now() - datetime.timedelta(
         seconds=interval + 5)
     """
     repeated_task_plan after processing should create new task
     repeated_task_plan_big_interval should not create new task because of bit interval
     """
     repeated_task_plan = TaskPlan(user_id=user_id,
                                   task_id=task_id,
                                   last_created_at=last_created_at,
                                   interval=interval)
     repeated_task_plan_big_interval = TaskPlan(
         user_id=user_id,
         task_id=task_id,
         last_created_at=last_created_at,
         interval=big_interval)
     self.task_plan_storage.create(repeated_task_plan)
     self.task_plan_storage.create(repeated_task_plan_big_interval)
     self.task_plan_storage.process_plans(self.task_storage)
     self.assertEqual(len(self.task_storage.user_tasks(user_id)),
                      before_tasks_count + 1)