def test_last_donation_today_is_may31_exit(self): ninetyfive_days_ago = datetime.now().date() - timedelta(days=95) today_may31 = datetime.strptime("2015.05.31", "%Y.%m.%d").date() with self.assertRaises(SystemExit): Validations.last_donation_more_than_three_month_ago( [ninetyfive_days_ago, today_may31])
def test_last_donation_today_is_may29(self): last_donation_date = datetime.strptime("2015.02.28", "%Y.%m.%d").date() today_may29 = datetime.strptime("2015.05.29", "%Y.%m.%d").date() self.assertTrue( Validations.last_donation_more_than_three_month_ago( [last_donation_date, today_may29]))
def test_last_donation_today_is_dec31(self): last_donation_date = datetime.strptime("2015.09.30", "%Y.%m.%d").date() today_dec31 = datetime.strptime("2015.12.31", "%Y.%m.%d").date() self.assertTrue( Validations.last_donation_more_than_three_month_ago( [last_donation_date, today_dec31]))
def test_last_donation_out_of_threemonth(self): ninetyfive_days_ago = datetime.now().date() - timedelta(days=95) self.assertTrue( Validations.last_donation_more_than_three_month_ago( ninetyfive_days_ago))
def test_last_donation_within_threemonth(self): eighty_eight_days_ago = datetime.now().date() - timedelta(days=88) with self.assertRaises(SystemExit): Validations.last_donation_more_than_three_month_ago( eighty_eight_days_ago)
def switcher(input_data, get_data): if get_data[0] == "Donor's name": if Validations.check_name(input_data): return NameFormat.name_corr_format(input_data) else: return False elif get_data[0] == "Birth date": if CheckDateFormat.check_date_format(input_data): input_data = donor_dates.get_date(input_data) input_data = Validations.validate_birthdate(input_data) return input_data else: return False elif get_data[0] == "Weight": return Validations.check_weight(input_data) elif get_data[0] == "Gender": return Validations.validate_gender(input_data) elif get_data[0] == "Unique ID": if Validations.check_uniqeid_exist(input_data): return Validations.validate_uniqeid(input_data) else: return False elif get_data[0] == "Expiration of ID": if CheckDateFormat.check_date_format(input_data): input_data = donor_dates.get_date(input_data) input_data = Validations.exp_uniqueid(input_data) return input_data else: return False elif get_data[0] == "Blood type": return Validations.blood_type_validation(input_data) elif get_data[0] == "Hemoglobin": return Validations.validate_hmg_from_keypad(input_data) elif get_data[0] == "Last donation date": if "never" in input_data.lower() or input_data.lower() == "n": return ["Never"] elif CheckDateFormat.check_date_format(input_data): input_data = donor_dates.get_date(input_data) input_data = Validations.last_donation_more_than_three_month_ago( input_data) return input_data else: return False elif get_data[0] == "Sickness": return Validations.check_arusicklastmonth(input_data) elif get_data[0] == "Mobile number": return Validations.validate_mobil_number(input_data) elif get_data[0] == "Email": return Validations.validate_email(input_data) elif get_data[0] == "Date of the event": if CheckDateFormat.check_date_format(input_data): input_data = donor_dates.get_date(input_data) if DateIsWeekday.is_date_weekday( input_data ) and DateTenDayBeforeEvent.is_date_ten_day_before_event( input_data): return input_data else: return False else: return False elif get_data[0] == "Start time": if CheckTimeFormat.check_time_form(input_data): return donor_dates.get_time(input_data) else: return False elif get_data[0] == "End time": if CheckTimeFormat.check_time_form(input_data): input_data = donor_dates.get_time(input_data) if EventCalculations.end_time_after_start_time( input_data, get_data[2]): return input_data else: return False else: return False elif get_data[0] == "City": if Address.validate_city(input_data): return NameFormat.name_corr_format(input_data) else: return False elif get_data[0] == "Zip code": return Address.check_zip_code(input_data) elif get_data[0] == "Available beds" or get_data[ 0] == "Planned donor number": return CheckIfPositiveInteger.check_if_positive_integer(input_data) elif get_data[0] == "Address": if Address.validate_address(input_data): return NameFormat.address_name_correct_form(input_data) else: return False