def test_close_time_sheet(self):
     time_sheet = TimeSheetProvider.create(
         date=datetime(2018, 1, 30),
         work_days_sheet=fixtures.load("january"),
         employee_id=0,
         employee_rate=RateCalculator.DAYS_FOR_3_YEARS,
         norm=22)
     time_sheet = TimeSheetProvider.close(time_sheet)
     try:
         TimeSheetProvider.update_with(time_sheet, 10)
         raise Exception("Closed time sheet has been updated")
     except AccessDeniedToUpdateTimeSheetError:
         self.assertEqual(time_sheet.closed, True)
    def test_update_time_sheet(self):
        time_sheet = TimeSheetProvider.create(
            date=datetime(2018, 1, 30),
            work_days_sheet=fixtures.load("january"),
            employee_id=0,
            employee_rate=RateCalculator.DAYS_FOR_3_YEARS,
            norm=22)
        time_sheet = TimeSheetProvider.update_with(time_sheet, norm=28)
        self.assertEqual(time_sheet.norm, 28)

        time_sheet = TimeSheetProvider.update_with(
            time_sheet, work_days_sheet=fixtures.load("february"))
        self.assertEqual(time_sheet.sheet, fixtures.load("february"))
Exemple #3
0
    def test_calculate_norm(self):
        time_sheet = TimeSheet()

        initializer = TimeSheetInitHelper(datetime(2018, 1, 1))
        time_sheet.sheet = initializer.empty_sheet
        time_sheet.norm = initializer.norm
        self.assertEqual(time_sheet.norm, 23)
        self.assertEqual(time_sheet.sheet.__len__(), 31)

        initializer = TimeSheetInitHelper(datetime(2018, 2, 1))
        time_sheet.sheet = initializer.empty_sheet
        time_sheet.norm = initializer.norm
        self.assertEqual(time_sheet.norm, 20)
        self.assertEqual(time_sheet.sheet.__len__(), 28)

        time_sheet = TimeSheetProvider.update_with(time_sheet, norm=17)
        self.assertEqual(time_sheet.norm, 17)