Exemplo n.º 1
0
    def test_partial_duplicate_holiday_end_last_week(self):


        last_friday = get_day_previous_week(4)
        holidays = {
                    2014:
                        [
                            {
                                'date': last_friday.date(),
                                'percent_used': 0.8
                            },
                            {
                                'date': last_friday.date(),
                                'percent_used': 0.8
                            }
                        ]
                    }

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, (self.hours_per_week - (self.hours_per_workday * 0.8)))
Exemplo n.º 2
0
    def test_full_holiday_report_day(self):
        holidays = {2014: [{'date': self.datetime_now.date()}]}

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 3
0
    def test_no_holiday_prev_year(self):

        holidays = {2014: []}

        start_date = datetime.datetime(2014, 12, 29)
        end_date = datetime.datetime(2015, 1, 4)

        workday = WorkDay(holidays, self.workdays,
                          datetime.datetime(2015, 1, 5))
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 4
0
    def test_full_holiday_mid_last_week(self):

        last_wednesday = get_day_previous_week(2)
        holidays = {2014: [{'date': last_wednesday.date()}]}

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed,
                         (self.hours_per_week - self.hours_per_workday))
Exemplo n.º 5
0
    def test_partial_holiday_beginning_last_week(self):

        last_monday = get_day_previous_week(0)
        holidays = {2014: [{'date': last_monday.date(), 'percent_used': 0.8}]}

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, (self.hours_per_week -
                                        (self.hours_per_workday * 0.8)))
Exemplo n.º 6
0
    def test_no_holiday_prev_year(self):

        holidays = {
                    2014:
                        [
                        ]
                    }

        start_date = datetime.datetime(2014, 12, 29)
        end_date = datetime.datetime(2015, 1, 4)

        workday = WorkDay(holidays, self.workdays, datetime.datetime(2015, 1, 5))
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 7
0
    def test_employee_join_mid_last_week_work_more_hours(self):
        last_wednesday = get_day_previous_week(2)
        last_wednesday = last_wednesday.strftime('%Y-%m-%dT%H:%M:%S+00:00')
        holidays = {2014: []}
        user = {
            'active': True,
            'admin': True,
            'at': last_wednesday,
            'avatar_file_name': 'randomurl.txt',
            'email': '*****@*****.**',
            'id': 321,
            'inactive': False,
            'name': 'Unit Test',
            'togglURL': 'randomurl',
            'uid': 123,
            'wid': 456
        }
        users_to_contact = []
        dummy_user = User(user, 37.5, 0)
        dummy_user.new_flag = True
        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)
        hours_reduction = dummy_user.hour_reduction(workday,
                                                    self.hours_per_workday,
                                                    start_date, end_date)
        dummy_user.setup_missing_hours((3 * self.hours_per_workday),
                                       users_to_contact, hours_reduction)

        self.assertGreater(100, dummy_user.percent_worked)
Exemplo n.º 8
0
    def test_employee_join_mid_last_week(self):
        last_wednesday = get_day_previous_week(2)
        last_wednesday = last_wednesday.strftime('%Y-%m-%dT%H:%M:%S+00:00')
        holidays = {2014: []}
        user = {
            'active': True,
            'admin': True,
            'at': last_wednesday,
            'avatar_file_name': 'randomurl.txt',
            'email': '*****@*****.**',
            'id': 321,
            'inactive': False,
            'name': 'Unit Test',
            'togglURL': 'randomurl',
            'uid': 123,
            'wid': 456
        }
        dummy_user = User(user, 37.5, 0)
        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)
        hours_reduction = dummy_user.hour_reduction(workday,
                                                    self.hours_per_workday,
                                                    start_date, end_date)
        required_hours = self.hours_per_week - hours_reduction

        self.assertEqual(3 * self.hours_per_workday, required_hours)
Exemplo n.º 9
0
    def test_full_holiday_report_day(self):
        holidays = {
                    2014:
                        [
                            {
                                'date': self.datetime_now.date()
                            }
                        ]
                    }

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 10
0
    def test_full_holiday_mid_last_week(self):

        last_wednesday = get_day_previous_week(2)
        holidays = {
                    2014:
                        [
                            {
                                'date': last_wednesday.date()
                            }
                        ]
                    }

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, (self.hours_per_week - self.hours_per_workday))
Exemplo n.º 11
0
    def test_partial_holiday_mid_week_prev_year(self):

        holidays = {
                    2014:
                        [
                            {
                                'date': datetime.date(2014, 12, 31),
                                'percent_used': 0.8
                            }
                        ]
                    }

        start_date = datetime.datetime(2014, 12, 29)
        end_date = datetime.datetime(2015, 1, 4)

        workday = WorkDay(holidays, self.workdays, datetime.datetime(2015, 1, 5))
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, (self.hours_per_week - (self.hours_per_workday * 0.8)))
Exemplo n.º 12
0
    def test_partial_holiday_mid_week_prev_year(self):

        holidays = {
            2014: [{
                'date': datetime.date(2014, 12, 31),
                'percent_used': 0.8
            }]
        }

        start_date = datetime.datetime(2014, 12, 29)
        end_date = datetime.datetime(2015, 1, 4)

        workday = WorkDay(holidays, self.workdays,
                          datetime.datetime(2015, 1, 5))
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, (self.hours_per_week -
                                        (self.hours_per_workday * 0.8)))
Exemplo n.º 13
0
    def test_full_duplicate_holiday_weekend(self):

        last_saturday = get_day_previous_week(5)
        holidays = {
            2014: [{
                'date': last_saturday.date()
            }, {
                'date': last_saturday.date()
            }]
        }

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(
            self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 14
0
    def test_partial_holiday_weekend(self):

        last_saturday = get_day_previous_week(5)
        holidays = {
                    2014:
                        [
                            {
                                'date': last_saturday.date(),
                                'percent_used': 0.8
                            }
                        ]
                    }

        start_date = get_day_previous_week()
        end_date = get_day_previous_week(6)

        workday = WorkDay(holidays, self.workdays, self.datetime_now)
        hours_needed = workday.calculate_total_work_hours(self.hours_per_workday, start_date, end_date)

        self.assertEqual(hours_needed, self.hours_per_week)
Exemplo n.º 15
0
user_list_response = api.get_workspace_members(settings['workspace_id'])
last_monday = get_day_previous_week()
last_sunday = get_day_previous_week(6)

logging.debug(last_monday)
logging.debug(last_sunday)

start_date = last_monday.strftime('%Y-%m-%d')
end_date = last_sunday.strftime('%Y-%m-%d')

logging.debug(start_date)
logging.debug(end_date)

# Minimum Hours Calculation
holidays_yml_stream = WorkDay.get_holidays_stream()
holidays = yaml.load(holidays_yml_stream)
now = WorkDay.get_now()
workDays = WorkDay(holidays, configs['work_days'], now)
minimum_hours_for_week = workDays.calculate_total_work_hours(7.5, last_monday, last_sunday)

users = user_list_response.json()
users_to_contact = []
users_queried = []


print "\n\nTime Tracked for " + start_date + " until " + end_date
print "Minimum Hours Required: " + str(minimum_hours_for_week) + "\n"

users_to_contact = []
users_to_output = []
Exemplo n.º 16
0
user_list_response = api.get_workspace_members(settings['workspace_id'])
last_monday = get_day_previous_week()
last_sunday = get_day_previous_week(6)

logging.debug(last_monday)
logging.debug(last_sunday)

start_date = last_monday.strftime('%Y-%m-%d')
end_date = last_sunday.strftime('%Y-%m-%d')

logging.debug(start_date)
logging.debug(end_date)

# Minimum Hours Calculation
holidays_yml_stream = WorkDay.get_holidays_stream()
holidays = yaml.load(holidays_yml_stream)
now = WorkDay.get_now()
workDays = WorkDay(holidays, configs['work_days'], now)
minimum_hours_for_week = workDays.calculate_total_work_hours(
    7.5, last_monday, last_sunday)

users = user_list_response.json()
users_to_contact = []
users_queried = []

print "\n\nTime Tracked for " + start_date + " until " + end_date
print "Minimum Hours Required: " + str(minimum_hours_for_week) + "\n"

users_to_contact = []
users_to_output = []