Exemplo n.º 1
0
    def test_next_under(self):
        employee = Employee()
        employee.id = 1
        employee.salary = 89752
        employee.fte = Decimal(.83)

        assignment = Assignment()
        assignment.start_date = date(2013, 11, 1)
        assignment.end_date = date(2014, 4, 30)
        assignment.effort = 70
        assignment.project_id = 1
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date = date(2013, 11, 1)
        assignment.end_date = date(2014, 4, 30)
        assignment.effort = 13
        assignment.project_id = 2
        assignment.role_id = 1
        employee.assignments.add(assignment)

        actual = employee.next_under(start_date=date(2014, 1, 1))
        self.assertEqual((2014,5), actual)

        employee.assignments.all().delete()

        assignment = Assignment()
        assignment.start_date = date(2013, 11, 1)
        assignment.end_date = date(2014, 4, 30)
        assignment.effort = 70
        assignment.project_id = 1
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date = date(2013, 11, 1)
        assignment.end_date = date(2014, 3, 31)
        assignment.effort = 13
        assignment.project_id = 2
        assignment.role_id = 1
        employee.assignments.add(assignment)

        actual = employee.next_under(start_date=date(2014, 1, 1))
        self.assertEqual((2014,4), actual)
Exemplo n.º 2
0
    def test_get_efforts(self):
        employee = Employee()
        employee.id = 1
        employee.project_id = 1

        prv1 = Assignment()
        prv1.start_date =  date(2014, 2, 1)
        prv1.end_date = date(2014, 4, 30)
        prv1.effort = 25
        prv1.project_id = 1
        prv1.role_id = 1
        employee.assignments.add(prv1)

        prv2 = Assignment()
        prv2.start_date =  date(2014, 3, 1)
        prv2.end_date = date(2014, 6, 30)
        prv2.effort = 50
        prv2.project_id = 2
        prv2.role_id = 1
        employee.assignments.add(prv2)

        new_assignment = Assignment()
        new_assignment.start_date = date(2014, 1,1)
        new_assignment.end_date = date(2014, 1, 31)
        new_assignment.effort = 10
        new_assignment.project_id = 3
        new_assignment.role_id = 1
        new_assignment.employee = employee

        efforts = new_assignment.get_efforts()
        self.assertEqual(1, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])

        new_assignment.end_date = date(2014, 2, 28)
        efforts = new_assignment.get_efforts()
        self.assertEqual(2, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])
        self.assertEqual(35, efforts[(2014,2)])

        new_assignment.end_date = date(2014, 3, 31)
        efforts = new_assignment.get_efforts()
        self.assertEqual(3, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])
        self.assertEqual(35, efforts[(2014,2)])
        self.assertEqual(85, efforts[(2014,3)])

        new_assignment.end_date = date(2014, 4, 30)
        efforts = new_assignment.get_efforts()
        self.assertEqual(4, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])
        self.assertEqual(35, efforts[(2014,2)])
        self.assertEqual(85, efforts[(2014,3)])
        self.assertEqual(85, efforts[(2014,4)])

        new_assignment.end_date = date(2014, 6, 30)
        efforts = new_assignment.get_efforts()
        self.assertEqual(6, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])
        self.assertEqual(35, efforts[(2014,2)])
        self.assertEqual(85, efforts[(2014,3)])
        self.assertEqual(85, efforts[(2014,4)])
        self.assertEqual(60, efforts[(2014,5)])
        self.assertEqual(60, efforts[(2014,6)])

        new_assignment.end_date = date(2014, 7, 31)
        efforts = new_assignment.get_efforts()
        self.assertEqual(7, len(efforts))
        self.assertEqual(10, efforts[(2014,1)])
        self.assertEqual(35, efforts[(2014,2)])
        self.assertEqual(85, efforts[(2014,3)])
        self.assertEqual(85, efforts[(2014,4)])
        self.assertEqual(60, efforts[(2014,5)])
        self.assertEqual(60, efforts[(2014,6)])
        self.assertEqual(10, efforts[(2014,7)])

        new_assignment.start_date = date(2014, 2, 1)
        efforts = new_assignment.get_efforts()
        self.assertEqual(6, len(efforts))
        self.assertEqual(35, efforts[(2014,2)])
        self.assertEqual(85, efforts[(2014,3)])
        self.assertEqual(85, efforts[(2014,4)])
        self.assertEqual(60, efforts[(2014,5)])
        self.assertEqual(60, efforts[(2014,6)])
        self.assertEqual(10, efforts[(2014,7)])
Exemplo n.º 3
0
    def test_get_efforts_by_month(self):
        employee = Employee()
        employee.id = 1
        employee.project_id = 1
        employee.salary = 89752

        assignment = Assignment()
        assignment.start_date =  date(2013, 12, 1)
        assignment.end_date = date(2014, 4, 30)
        assignment.effort = 25
        assignment.project_id = 1
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date =  date(2014, 3, 1)
        assignment.end_date = date(2014, 6, 30)
        assignment.effort = 50
        assignment.project_id = 2
        assignment.role_id = 1
        employee.assignments.add(assignment)

        assignment = Assignment()
        assignment.start_date =  date(2014, 1, 1)
        assignment.end_date = date(2014, 3, 31)
        assignment.effort = 10
        assignment.project_id = 3
        assignment.role_id = 1
        employee.assignments.add(assignment)

        efforts = employee.get_efforts_by_month()
        self.assertEqual(7, len(efforts))
        self.assertEqual(EffortCost(25, to_money(1869.83)), efforts[EffortMonth(2013, 12)])
        self.assertEqual(EffortCost(35, to_money(2617.76)), efforts[EffortMonth(2014, 1)])
        self.assertEqual(EffortCost(35, to_money(2617.76)), efforts[EffortMonth(2014, 2)])
        self.assertEqual(EffortCost(85, to_money(6357.43)), efforts[EffortMonth(2014, 3)])
        self.assertEqual(EffortCost(75, to_money(5609.50)), efforts[EffortMonth(2014, 4)])
        self.assertEqual(EffortCost(50, to_money(3739.67)), efforts[EffortMonth(2014, 5)])
        self.assertEqual(EffortCost(50, to_money(3739.67)), efforts[EffortMonth(2014, 6)])