def validate_args(self, submit_date, turnaround_hours):
        if not Validation.is_valid_date(submit_date):
            raise TypeError("Invalid submit. Date should be python datetime.")

        if not Validation.is_valid_turnaround_hours(turnaround_hours):
            raise TypeError("Invalid turnaround hours. It must be a non-negative int.")

        if not Validation.time_out_of_range(submit_date, [self.start_hour, self.end_hour]):
            error_msg = "Invalid date.\
 Time must be between {} and {}".format(self.start_hour, self.end_hour)
            raise ValueError(error_msg)
        if not Validation.is_date_on_weekday(submit_date):
            raise ValueError("Invalid date. The given date is on a weekend.")
Beispiel #2
0
 def test_is_date_on_weekday_false(self):
     test_date = dt.datetime(2018, 10, 20, 13, 20)
     self.assertFalse(Validation.is_date_on_weekday(test_date))
 def add_days(date):
     temp_date = date + dt.timedelta(days=1)
     while Validation.is_date_on_weekday(temp_date) is False:
         temp_date += dt.timedelta(days=1)
     return temp_date
Beispiel #4
0
 def test_is_date_on_weekday_true(self):
     test_date = dt.datetime(2018, 10, 19, 12, 40)
     self.assertTrue(Validation.is_date_on_weekday(test_date))