def test_max_donor_with_2_beds(self): vampireparty = Event() vampireparty.start_time = '10:00' vampireparty.end_time = '18:00' vampireparty.duration = vampireparty.calculate_duration() vampireparty.available_beds = 2 self.assertEqual(vampireparty.max_donor_number(), 30)
def add_new_donation_event(cursor_object): print("Adding new event...\n") time.sleep(1) clear() e1 = Event() while True: e1.date_of_event = input("Date of Event: ") if Validate.validate_date(e1.date_of_event) and e1.registration_in_tendays(): pass else: print("\n\t ! The registration should be at least 10 days from now. ! ") print("\t ! Use this format to enter date: 'YYYY.MM.DD' ! \n") time.sleep(2) clear() continue e1.start_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "Start Time: ", TIME_ERR) e1.end_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "End Time: ", TIME_ERR) while not e1.is_starttime_before_endtime(): print("\n\t ! The starting time should be before the ending time. ! ") time.sleep(2) clear() e1.end_time = "" e1.end_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "End Time: ", TIME_ERR) e1.zip_code = EventManagerDB.data_into_event_object(e1, Validate.validate_zipcode, "ZIP code: ", ZIP_ERR) e1.city = EventManagerDB.data_into_event_object(e1, Validate.validate_city_name, "City: ", CITY_ERR) e1.address = EventManagerDB.data_into_event_object(e1, Validate.validate_address, "Address of event: ", ADDRESS_ERR) e1.available_beds = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "Available beds: ", POSINT_ERR) e1.planned_donor_number = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "Planned donor number: ", POSINT_ERR) e1.successfull = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "\n How many successfull donation was on the event?\n > ", POSINT_ERR) print("\nThe required functions: \n") print("Weekday :", e1.is_weekday()) e1.duration = e1.calculate_duration() print("Duration: {} min -- {} hours ".format(e1.duration, round(e1.duration/60, 1))) print("Maximum donor number:", e1.max_donor_number()) print("Success rate: {}".format(e1.success_rate())) input("\n\n (Press ENTER to go BACK)") EventManagerDB.store_donation_data(e1, cursor_object) clear() break
def add_new_donation_event(): print("Adding new event...\n") time.sleep(1) clear() e1 = Event() while True: e1.date_of_event = input("Date of Event: ") if Validate.validate_date( e1.date_of_event) and e1.registration_in_tendays(): pass else: print( "\n\t ! The registration should be at least 10 days from now. ! " ) print( "\t ! Use this format to enter date: 'YYYY.MM.DD' ! \n") time.sleep(2) clear() continue e1.start_time = EventManagerCSV.data_in_e(e1, Validate.validate_time, "Start Time: ", TIME_ERR) e1.end_time = EventManagerCSV.data_in_e(e1, Validate.validate_time, "End Time: ", TIME_ERR) while not e1.is_starttime_before_endtime(): print( "\n\t ! The starting time should be before the ending time. ! " ) time.sleep(2) clear() e1.end_time = "" e1.end_time = EventManagerCSV.data_in_e( e1, Validate.validate_time, "End Time: ", TIME_ERR) e1.zip_code = EventManagerCSV.data_in_e(e1, Validate.validate_zipcode, "ZIP code: ", ZIP_ERR) e1.city = EventManagerCSV.data_in_e(e1, Validate.validate_city_name, "City: ", CITY_ERR) e1.address = EventManagerCSV.data_in_e(e1, Validate.validate_address, "Address of event: ", ADDRESS_ERR) e1.available_beds = EventManagerCSV.data_in_e( e1, Validate.validate_positive_int, "Available beds: ", POSINT_ERR) e1.planned_donor_number = EventManagerCSV.data_in_e( e1, Validate.validate_positive_int, "Planned donor number: ", POSINT_ERR) e1.successfull = EventManagerCSV.data_in_e( e1, Validate.validate_positive_int, "\n How many successfull donation was on the event?\n > ", POSINT_ERR) print("\nThe required functions: \n") print("Weekday :", e1.is_weekday()) e1.duration = e1.calculate_duration() print("Duration: {} min -- {} hours ".format( e1.duration, round(e1.duration / 60, 1))) print("Maximum donor number:", e1.max_donor_number()) print("Success rate: {}".format(e1.success_rate())) input("\n\n (Press ENTER to go BACK)") EventManagerCSV.store_donation_data(e1) clear() break