Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
    def test_method_get_all(self):
        work_task_repo = WorkTaskRepo()
        for i in range(10):
            db_work_task = WorkTaskORM.objects.create(
                title='Test Work Task',
                description='Test method create',
                paid=False,
                price=100,
                project_id=self.project.id,
                completed=True,
            )
            work_task_repo._decode_db_work_task(db_work_task)

        work_tasks = work_task_repo.get_all(self.project.id)
        self.assertEqual(type(work_tasks), list)
        self.assertEqual(len(work_tasks), 10)
Beispiel #4
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)
Beispiel #5
0
 def test_method__decode_db_work_task(self):
     work_task_repo = WorkTaskRepo()
     db_work_task = WorkTaskORM.objects.create(
         title='Test Work Task',
         description='Test method create',
         paid=False,
         price=100,
         project_id=self.project.id,
         completed=True,
     )
     work_task = work_task_repo._decode_db_work_task(db_work_task)
     self.assertEqual(work_task.id, db_work_task.id)
     self.assertEqual(work_task.title, db_work_task.title)
     self.assertEqual(work_task.description, db_work_task.description)
     self.assertEqual(work_task.paid, db_work_task.paid)
     self.assertEqual(work_task.completed, db_work_task.completed)
     self.assertEqual(work_task.project_id, db_work_task.project_id)
     self.assertEqual(work_task.price, db_work_task.price)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
0
 def create():
     return WorkTaskRepo()