def send( googlesheet_id: str = typer.Option(...), debug_level: DebugLevel = DebugLevel.ERROR, env_file: Path = typer.Option(None), dry_run: bool = typer.Option(False), ): """Send SMS messages.""" # STEP: connect to the spreadsheet, download it, and use it in follow-on steps dataframe, console, logger = connect_and_download(googlesheet_id, debug_level, env_file) # STEP: let the person using the program select individuals to receive the SMS chosen_individual_names_list = select_individuals(dataframe) # STEP: display the names of individuals who will receive the SMS display_recipients(chosen_individual_names_list, console) # STEP: get the phone numbers of the selected individuals phone_numbers_dictionary = extract.get_individual_numbers( dataframe, chosen_individual_names_list) logger.debug(f"Phone numbers: {phone_numbers_dictionary}") # STEP: get the activities for individuals name_activities_dictionary = extract.get_individual_activities( dataframe, chosen_individual_names_list) logger.debug(f"Individuals and activities: {name_activities_dictionary}") display_activities(name_activities_dictionary, console) # STEP: generate the messages for the individuals number_sms_dictionary = extract.get_sms_messages( phone_numbers_dictionary, name_activities_dictionary) logger.debug(f"Phone numbers and SMS messages: {number_sms_dictionary}") display_sms(number_sms_dictionary, console, dry_run) # STEP: send the SMS messages for each individual if not dry_run: sid = sms.send_messages(number_sms_dictionary) logger.debug(f"Twilio returned SID: {sid}")
def test_extract_get_phone_numbers_no_matching_person_empty_list(): """Ensure that it is possible to get no matching person's telephone number from the data frame.""" dataframe = pandas.DataFrame({ "Individual Name": ["Gregory", "Jessica", "Madelyn"], "Individual Phone Number": ["888-111-5555", "888-222-5555", "888-333-5555"], }) individual_names_list = [] phone_numbers = extract.get_individual_numbers(dataframe, individual_names_list) assert phone_numbers is not None assert len(phone_numbers.keys()) == 0
def test_extract_get_phone_numbers_multiple_person(): """Ensure that it is possible to get multiple people's telephone number from the data frame.""" dataframe = pandas.DataFrame({ "Individual Name": ["Gregory", "Jessica", "Madelyn"], "Individual Phone Number": ["888-111-5555", "888-222-5555", "888-333-5555"], }) individual_names_list = ["Madelyn", "Gregory"] phone_numbers = extract.get_individual_numbers(dataframe, individual_names_list) assert phone_numbers is not None assert len(phone_numbers.keys()) == 2 assert phone_numbers["Madelyn"] == "888-333-5555" assert phone_numbers["Gregory"] == "888-111-5555"