示例#1
0
    def test_method_update(self):
        work_task_repo = WorkTaskRepo()
        work_task = WorkTask(
            title='Test Work Task',
            description='Test method create',
            paid=True,
            price=100,
            project_id=self.project.id,
            completed=True,
        )

        work_task_create = work_task_repo.create(work_task)

        work_task_update_1 = WorkTask(
            id=work_task_create.id,
            title='Test Work Task Update',
            description='Test method create update',
            price=150,
            paid=False,
            project_id=25616,   # не дожен изменятся
            completed=work_task_create.completed,
        )

        work_task_update = work_task_repo.update(work_task_update_1)

        self.assertEqual(work_task_update.title, 'Test Work Task Update')
        self.assertEqual(work_task_update.description, 'Test method create update')
        self.assertEqual(work_task_update.paid, False)
        self.assertEqual(work_task_update.completed, True)
        self.assertEqual(work_task_update.project_id, work_task_create.project_id)
        self.assertEqual(work_task_update.price, 150)
示例#2
0
    def test_method_delete(self):
        work_task_repo = WorkTaskRepo()
        work_task = WorkTask(
            title='Test Work Task',
            description='Test method create',
            paid=False,
            price=100,
            project_id=self.project.id,
            completed=True,
        )
        work_task_create = work_task_repo.create(work_task)
        self.assertIsNotNone(work_task_repo.get(work_task_create.id))
        self.assertIsNotNone(WorkTaskORM.objects.get(id=work_task_create.id))

        work_task_delete = work_task_repo.delete(work_task_create.id)

        with self.assertRaises(EntityDoesNotExistException):
            work_task_repo.get(work_task_create.id)

        with self.assertRaises(WorkTaskORM.DoesNotExist):
            WorkTaskORM.objects.get(id=work_task_create.id)

        self.assertEqual(work_task_delete.title, 'Test Work Task')
        self.assertEqual(work_task_delete.description, 'Test method create')
        self.assertEqual(work_task_delete.paid, False)
        self.assertEqual(work_task_delete.completed, True)
        self.assertEqual(work_task_delete.project_id, self.project.id)
        self.assertEqual(work_task_delete.price, 100)
示例#3
0
    def test_method___get_entity_type_list_task_of_payment(self):
        COUNT_TASK = 10
        project = Project(
            title='Test Project',
            description='My Test project',
            type_of_payment='T_P',
            start_date=datetime.datetime.now(),
            user_id=self.user.id
        )

        project_create = self.project_repo.create(project)
        work_task_repo = WorkTaskRepo()

        for i in range(COUNT_TASK):
            work_task = WorkTask(
                title='Test Work Task',
                description='Test method create',
                paid=False,
                price=100,
                project_id=project_create.id,
                completed=True,
            )

            work_task_repo.create(work_task)

        work_tasks = self.project_repo._get_entity_type_list(project_create.id)
        self.assertEqual(type(work_tasks), list)
        self.assertEqual(len(work_tasks), COUNT_TASK)
        self.assertEqual(type(work_tasks.pop()), WorkTask)
        self.assertNotEqual(type(work_tasks.pop()), HourPayment)
        self.assertNotEqual(type(work_tasks.pop()), MonthPayment)
示例#4
0
    def setUp(self):
        self.worked_days = []
        self.work_times = []
        for i in range(10):
            worked_day = WorkedDay(month_payment_id=i,
                                   day=datetime.now().date() -
                                   timedelta(days=10 - i),
                                   paid=False)
            self.worked_days.append(worked_day)
        for i in range(10):
            work_time = WorkTime(
                id=i,
                hour_payment_id=1,
                start_work=datetime.now().replace(
                    hour=10, minute=0, second=0) - timedelta(days=10 - i),
                end_work=datetime.now().replace(hour=19, minute=0, second=0) -
                timedelta(days=10 - i),
                paid=False)
            self.work_times.append(work_time)

        self.tasks = []
        for i in range(10):
            task = WorkTask(
                id=i,
                project_id=1,
                price=(i + 1) * 100,
            )
            self.tasks.append(task)
示例#5
0
    def _decode_db_work_task(self, db_work_task):
        fields = {
            'id': db_work_task.id,
            'project_id': db_work_task.project.id,
            'title': db_work_task.title,
            'description': db_work_task.description,
            'price': db_work_task.price,
            'completed': db_work_task.completed,
            'paid': db_work_task.paid
        }

        return WorkTask(**fields)
示例#6
0
 def test_method_get(self):
     work_task_repo = WorkTaskRepo()
     work_task = WorkTask(
         title='Test Work Task',
         description='Test method create',
         paid=False,
         price=100,
         project_id=self.project.id,
         completed=True,
     )
     work_task_create = work_task_repo.create(work_task)
     work_task_get = work_task_repo.get(work_task_create.id)
     self.assertEqual(work_task_get.title, work_task_create.title)
     self.assertEqual(work_task_get.description, work_task_create.description)
     self.assertEqual(work_task_get.paid, work_task_create.paid)
     self.assertEqual(work_task_get.completed, work_task_create.completed)
     self.assertEqual(work_task_get.project_id, work_task_create.project_id)
     self.assertEqual(work_task_get.price, work_task_create.price)
     with self.assertRaises(EntityDoesNotExistException):
         work_task_repo.get(work_task_create.id + 56165156)
示例#7
0
    def test_method_create(self):
        work_task_repo = WorkTaskRepo()
        work_task = WorkTask(
            title='Test Work Task',
            description='Test method create',
            paid=False,
            price=100,
            project_id=self.project.id,
            completed=True,
        )
        work_task_create = work_task_repo.create(work_task)
        self.assertEqual(work_task_create.title, 'Test Work Task')
        self.assertEqual(work_task_create.description, 'Test method create')
        self.assertEqual(work_task_create.paid, False)
        self.assertEqual(work_task_create.completed, True)

        db_work_task = WorkTaskORM.objects.get(id=work_task_create.id)

        self.assertEqual(db_work_task.title, work_task_create.title)
        self.assertEqual(db_work_task.description, work_task_create.description)
        self.assertEqual(db_work_task.paid, work_task_create.paid)
        self.assertEqual(db_work_task.completed, work_task_create.completed)
        self.assertEqual(db_work_task.project_id, work_task_create.project_id)
        self.assertEqual(db_work_task.price, work_task_create.price)
示例#8
0
 def create(**kwargs):
     return WorkTask(**kwargs)