예제 #1
0
    def test_get_holidays_year(self):
        holidays = Holiday.get_holidays_for_year(2017)
        self.assertEqual(len(holidays), 4)
        self.assertListEqual(holidays, [
            self.new_years.to_json(2017),
            self.christmas_eve.to_json(2017),
            self.christmas.to_json(2017),
            self.new_years_eve.to_json(2017),
        ])

        holidays = Holiday.get_holidays_for_year(2018)
        self.assertEqual(len(holidays), 4)
        self.assertListEqual(holidays, [
            self.new_years.to_json(2018),
            self.christmas_eve.to_json(2018),
            self.christmas.to_json(2018),
            self.new_years_eve.to_json(2018),
        ])

        holidays = Holiday.get_holidays_for_year(2019)
        self.assertEqual(len(holidays), 4)
        self.assertListEqual(holidays, [
            self.new_years.to_json(2019),
            self.christmas_eve.to_json(2019),
            self.christmas.to_json(2019),
            self.new_years_eve.to_json(2019),
        ])
예제 #2
0
    def test_get_holidays_year(self):
        holidays = Holiday.get_holidays_for_year(2017)
        self.assertEqual(len(holidays), 1)
        self.assertDictEqual(holidays[0], self.easter_2017.to_json())

        holidays = Holiday.get_holidays_for_year(2018)
        self.assertEqual(len(holidays), 1)
        self.assertDictEqual(holidays[0], self.easter_2018.to_json())

        holidays = Holiday.get_holidays_for_year(2019)
        self.assertEqual(len(holidays), 0)
예제 #3
0
    def available_hours(self):
        end_date = self.cached_due_date
        if end_date is None or self.effort is None:
            # TODO: what is an appropriate amount of effort (man-days) to set
            #       for a task that has no effort or no due date?  Right now
            #       we set at 2 hours (a quarter-day)
            return 0.25 # or 0.0?
        else:
            if type(end_date) is datetime.datetime:
                end_date = end_date.date()
            # get holidays in years covered across today through
            # requested/scheduled date
            holidays = []
            ptor_time = 0.0
            for year in range(datetime.date.today().year, end_date.year+1):
                holiday_dates = [h['date'] for h in Holiday.get_holidays_for_year(year, {'paid_holiday':True})]
                holidays.extend(holiday_dates)
            
                # also add paid time off requests that have been approved as non working days
                if self.assignee:
                    for ptor in PaidTimeOffRequest.objects.filter(Q(pto_start_date__year=year)|Q(pto_end_date__year=year)
                        ).filter(Q(status=PaidTimeOffRequest.APPROVED)|Q(status=PaidTimeOffRequest.PROCESSED)
                        ).filter(user_profile=self.assignee.profile):
                        for i in range((ptor.pto_end_date-ptor.pto_start_date).days):
                            holidays.append(ptor.pto_start_date+datetime.timedelta(days=i))
                        if float(ptor.amount) < 8.0:
                            ptor_time += 8.0 - float(ptor.amount)

            # get number of workdays found in between the today and end_date
            num_workdays = workdays.networkdays(datetime.date.today(),
                                                end_date,
                                                holidays)
            num_workdays = num_workdays - (float(ptor_time)/8.0)
            return 8.0 * max(0.5,num_workdays)
예제 #4
0
    def test_get_holidays_year(self):
        holidays = Holiday.get_holidays_for_year(2017)
        self.assertEqual(len(holidays), 2)
        self.assertListEqual(holidays, [
            self.electionday.to_json(2017),
            self.blackfriday.to_json(2017),
        ])

        holidays = Holiday.get_holidays_for_year(2018)
        self.assertEqual(len(holidays), 2)
        self.assertListEqual(holidays, [
            self.electionday.to_json(2018),
            self.blackfriday.to_json(2018),
        ])

        holidays = Holiday.get_holidays_for_year(2019)
        self.assertEqual(len(holidays), 2)
        self.assertListEqual(holidays, [
            self.electionday.to_json(2019),
            self.blackfriday.to_json(2019),
        ])
예제 #5
0
    def test_get_holidays_year(self):
        holidays = Holiday.get_holidays_for_year(2017)
        self.assertEqual(len(holidays), 3)
        self.assertListEqual(holidays, [
            self.mlkday.to_json(2017),
            self.laborday.to_json(2017),
            self.thanksgiving.to_json(2017),
        ])

        holidays = Holiday.get_holidays_for_year(2018)
        self.assertEqual(len(holidays), 3)
        self.assertListEqual(holidays, [
            self.mlkday.to_json(2018),
            self.laborday.to_json(2018),
            self.thanksgiving.to_json(2018),
        ])

        holidays = Holiday.get_holidays_for_year(2019)
        self.assertEqual(len(holidays), 3)
        self.assertListEqual(holidays, [
            self.mlkday.to_json(2019),
            self.laborday.to_json(2019),
            self.thanksgiving.to_json(2019),
        ])