modules/date_helper.py
def add_or_subtract_days(date, num_of_days):
	return date + relativedelta(days=num_of_days)
modules/upload_contacts_from_file.py
def assign_preg_signup(row, headers):
    row_entry = entry_or_empty_string(row=row, headers=headers).lower()
    if not row_entry:
        return False
    elif "pregnant" in row_entry:
        return True
    elif row_entry[0] == "1" or row_entry[0] == "t":
        return True
    else:
        return False
modules/upload_contacts_from_file.py
def determine_language(row, headers):
    language_entry = check_all_headers(row=row, headers=headers)
    return language_selector(language_input=language_entry, options=["Hindi", "English", "Gujarati"],
        default_option="Hindi", none_option="Hindi")
modules/upload_contacts_from_file.py
def parse_or_create_functional_dob(row, headers, source, date_of_birth, delay):
    row_entry = check_all_headers(row=row, headers=headers)
    return entered_date_string_to_date(row=row, headers=headers, source=source) if row_entry else add_or_subtract_days(date_of_birth, delay)
modules/upload_contacts_from_file.py
def parse_or_create_delay_num(row, headers):
    delay_input = check_all_headers(row=row, headers=headers)
    if delay_input is None:
        return 0
    else:
        delay_input = delay_input.replace(",", "")
    return int(delay_input) if delay_input and not re.search("\D+", delay_input) else 0
modules/i18n.py
def hindi_placeholder_name():
    return u'\u0906\u092a\u0915\u093e \u0936\u093f\u0936\u0941'
modules/upload_contacts_from_file.py
def language_selector(language_input, options, default_option, none_option):
    language_input = re.sub("\W", "", str(language_input))
    if not language_input:
        return none_option

    if language_input in options:
        return language_input
    elif language_input[0] == "1":
        return "Hindi"
    elif language_input[0] == "2":
        return "English"
    elif language_input[0] == "3":
        return options[2]
    else:
        return default_option
modules/upload_contacts_from_file.py
def entry_or_empty_string(row, headers):
    row_entry = check_all_headers(row=row, headers=headers)
    return "" if row_entry is None else row_entry 
modules/upload_contacts_from_file.py
def determine_mother_tongue(row, headers):
    mother_tongue = check_all_headers(row=row, headers=headers)
    return language_selector(language_input=mother_tongue, options=["Hindi", "English", "Other"],
        default_option="", none_option="")
modules/upload_contacts_from_file.py
def determine_date_of_birth(row, dob_headers, month_headers, date_of_signup, preg_signup, source):
    date_of_birth_entry = entry_or_empty_string(row=row, headers=dob_headers)

    if preg_signup and not date_of_birth_entry:
        month_of_pregnancy = filter_pregnancy_month(row=row, headers=month_headers)
        return estimate_date_of_birth(month_of_pregnancy=month_of_pregnancy, date_of_sign_up=date_of_signup)

    return entered_date_string_to_date(row=row, headers=dob_headers, source=source)
modules/upload_contacts_from_file.py
def determine_name(row, headers, language):
    nickname = row.get("Nick Name of Child")
    if not nickname or nickname == len(nickname) * " ":
        name_entry = entry_or_empty_string(row=row, headers=headers)
        return replace_blank_name(name_entry.encode("utf-8").decode('unicode-escape'), language)
    else:
        return nickname.encode("utf-8").decode('unicode-escape')
modules/date_helper.py
def add_or_subtract_months(date, num_of_months):
	return date + relativedelta(months=num_of_months)
modules/utils.py
def phone_number_is_valid(phone_number):
    """Match any number starting with 91 or +91 that has another
        9 to 15 digits"""
    pattern = '^\+?91?\d{9,15}$'
    prepared_phone_number = prepare_phone_number(phone_number)
    return re.match(pattern, prepared_phone_number)
modules/upload_contacts_from_file.py
def matching_permutation(row, header):
    permutations = [header, header + " ", " " + header + " ",
                    header + ",", header + ".", "The " + header,
                    header[0:-1], header[1:]]

    for perm in permutations:
        if row.get(perm):
            return perm
        elif row.get(perm.capitalize()):
            return perm.capitalize()
        elif row.get(perm.title()):
            return perm.title()
        elif row.get(perm.upper()):
            return perm.upper()
        elif row.get(perm.lower()):
            return perm.lower()
    
    return None
management/models.py
class Contact(models.Model):
    # Vitals
    name = models.CharField(max_length=50)
    phone_regex = RegexValidator(regex=r'^\+?91?\d{9,15}$',
        message="Phone number must be entered in the format: '+9199999999'. Up to 15 digits allowed.",
        code="Invalid phone_number")
    phone_number = models.CharField(validators=[phone_regex], blank=False,
        max_length=20, default="012345") # validators should be a list
    alt_phone_number = models.CharField(validators=[phone_regex], blank=False,
        max_length=20, default="012345")
    date_of_birth = models.DateField(auto_now=False, auto_now_add=False,
        default=datetime.date.today)
    date_of_sign_up = models.DateField(auto_now=False, auto_now_add=False,
        default=datetime.date.today)
    delay_in_days = models.SmallIntegerField(default=0, blank=True)
    functional_date_of_birth = models.DateField(blank=True,auto_now=False,
        auto_now_add=False, default=datetime.date.today)
    cancelled = models.BooleanField(default=False, blank=False)

    # Personal Info
    gender = models.CharField(max_length=6, blank=True)
    mother_tongue = models.CharField(max_length=50, blank=True)
    state = models.CharField(max_length=50, blank=True)
    division = models.CharField(max_length=50, blank=True)
    district = models.CharField(max_length=50, blank=True)
    city = models.CharField(max_length=50, blank=True)
    monthly_income_rupees = models.IntegerField(blank=True, default=999999)
    religion = models.CharField(max_length=50, blank=True)
    children_previously_vaccinated = models.NullBooleanField()
    not_vaccinated_why = models.CharField(max_length=500, blank=True)
    mother_first_name = models.CharField(max_length=50, blank=True)
    mother_last_name = models.CharField(max_length=50, blank=True)
    
    # Type of Sign Up
    method_of_sign_up = models.CharField(max_length=50, blank=True)
    org_sign_up = models.CharField(max_length=40, blank=True)
    hospital_name = models.CharField(max_length=50, blank=True)
    doctor_name = models.CharField(max_length=30, blank=True)
    preg_signup = models.NullBooleanField(default=False)
    preg_update = models.NullBooleanField(default=False)

    def has_been_born(self):
        today = datetime.date.today()
        diff = today - self.date_of_birth
        return  diff >= datetime.timedelta(0)


    # System Identification
    telerivet_contact_id = models.CharField(max_length=50, blank=True)
    trial_id = models.CharField(max_length=40, blank=True)
    trial_group = models.CharField(max_length=40, blank=True)    


    language_preference = models.CharField(max_length=20,
        default="English", blank=False, null=False)

    # Message References
    preferred_time = models.CharField(max_length=50, blank=True)
    script_selection = models.CharField(max_length=20, blank=True)
    telerivet_sender_phone = models.CharField(max_length=100, blank=True)
    time_created = models.DateField(auto_now=False, auto_now_add=False,
        default=datetime.date.today)
    last_heard_from = models.DateTimeField(auto_now=False, auto_now_add=False, blank=True,
        null=True)
    last_contacted = models.DateTimeField(auto_now=False, auto_now_add=False, blank=True,
        null=True)

    def __str__(self):
        return "%s, %s, %s" % (self.name, self.phone_number, self.date_of_birth)

    class Meta:
        ordering = ('name',)
modules/upload_contacts_from_file.py
def assign_org_signup(row, headers, source):
    return source.upper() if source.upper() != "TR" else entry_or_empty_string(row=row, headers=headers)
modules/upload_contacts_from_file.py
def time_reference_or_none(row, headers):
    row_entry = check_all_headers(row=row, headers=headers)
    return datetime_string_mdy_to_datetime(row_entry) if row_entry else None
modules/upload_contacts_from_file.py
def entered_date_string_to_date(row, headers, source):
    row_entry = check_all_headers(row=row, headers=headers)
    return try_parsing_gen_date(row_entry) if source == "TR" else try_parsing_partner_date(row_entry)
modules/upload_contacts_from_file.py
def csv_upload(filepath, source):
    with open(filepath) as csvfile:
        reader = csv.DictReader(csvfile)
        for row in reader:
            new_dict = make_contact_dict(row, source)
            if phone_number_is_valid(new_dict["phone_number"]):
                new_contact, created = Contact.objects.update_or_create(name=new_dict["name"],
                    phone_number=new_dict["phone_number"], defaults=new_dict)

                assign_groups_to_contact(new_contact, row.get("Groups"))
            else:
                logging.error("Entry: {name} - {date_of_birth} has invalid phone number: {phone}".format(
                    name=new_dict["name"], phone=new_dict["phone_number"], date_of_birth=new_dict["date_of_birth"]))
modules/upload_contacts_from_file.py
def make_contact_dict(row, source):
    new_dict = {}
    headers = column_headers()
    new_dict["language_preference"] = determine_language(row=row, headers=headers["language_preference"])
    new_dict["name"] = determine_name(row=row, headers=headers["name"], language=new_dict["language_preference"]) 
    new_dict["phone_number"] = prepare_phone_number(check_all_headers(row=row, headers=headers["phone_number"]))
    new_dict["alt_phone_number"] = prepare_phone_number(check_all_headers(row=row, headers=headers["alt_phone_number"]))
    new_dict["delay_in_days"] = parse_or_create_delay_num(row=row, headers=headers["delay_in_days"])
    new_dict["date_of_sign_up"] = entered_date_string_to_date(row=row, headers=headers["date_of_sign_up"], source=source)
    new_dict["preg_signup"] = assign_preg_signup(row=row, headers=headers["preg_signup"])
    new_dict["date_of_birth"] = determine_date_of_birth(row=row, dob_headers=headers["date_of_birth"],
        month_headers=headers["month_of_pregnancy"], date_of_signup=new_dict["date_of_sign_up"],
        preg_signup=new_dict["preg_signup"], source=source)
    new_dict["functional_date_of_birth"] = parse_or_create_functional_dob(row=row, headers=headers["functional_date_of_birth"],
        source=source, date_of_birth=new_dict["date_of_birth"], delay=new_dict["delay_in_days"])

    # Personal Info
    new_dict["gender"] = entry_or_empty_string(row=row, headers=headers["gender"])
    new_dict["mother_tongue"] = determine_mother_tongue(row=row, headers=headers["mother_tongue"])
    new_dict["religion"] = entry_or_empty_string(row=row, headers=headers["religion"])
    new_dict["state"] = entry_or_empty_string(row=row, headers=headers["state"])
    new_dict["division"] = entry_or_empty_string(row=row, headers=headers["division"])
    new_dict["district"] = entry_or_empty_string(row=row, headers=headers["district"])
    new_dict["city"] = entry_or_empty_string(row=row, headers=headers["city"])
    new_dict["monthly_income_rupees"] = monthly_income(row=row, headers=headers["monthly_income_rupees"])
    new_dict["children_previously_vaccinated"] = previous_vaccination(row=row, headers=headers["children_previously_vaccinated"])
    new_dict["not_vaccinated_why"] = entry_or_empty_string(row=row, headers=headers["not_vaccinated_why"])
    new_dict["mother_first_name"] = entry_or_empty_string(row=row, headers=headers["mother_first_name"])
    new_dict["mother_last_name"] = entry_or_empty_string(row=row, headers=headers["mother_last_name"])

    # Type of Sign Up
    new_dict["method_of_sign_up"] = assign_method_of_signup(row=row, headers=headers["method_of_sign_up"], source=source)
    new_dict["org_sign_up"] = assign_org_signup(row=row, headers=headers["org_sign_up"], source=source)
    new_dict["hospital_name"] = assign_hospital_name(row=row, headers=headers["hospital_name"],
        method_of_signup=new_dict["method_of_sign_up"], org_signup=new_dict["org_sign_up"])
    new_dict["doctor_name"] = entry_or_empty_string(row=row, headers=headers["doctor_name"])

    # System Identification
    new_dict["telerivet_contact_id"] = entry_or_empty_string(row=row, headers=headers["telerivet_contact_id"])
    new_dict["trial_id"] = entry_or_empty_string(row=row, headers=headers["trial_id"])
    new_dict["trial_group"] = entry_or_empty_string(row=row, headers=headers["trial_group"])

    # Message References
    new_dict["preferred_time"] = entry_or_empty_string(row=row, headers=headers["preferred_time"])
    new_dict["script_selection"] = entry_or_empty_string(row=row, headers=headers["script_selection"])
    new_dict["telerivet_sender_phone"] = entry_or_empty_string(row=row, headers=headers["telerivet_sender_phone"])
    new_dict["last_heard_from"] = time_reference_or_none(row=row, headers=headers["last_heard_from"])
    new_dict["last_contacted"] = time_reference_or_none(row=row, headers=headers["last_contacted"])
    new_dict["time_created"] = parse_contact_time_references(row=row, headers=headers["time_created"])
    return new_dict
modules/upload_contacts_from_file.py
def replace_blank_name(name, language):
    if not name or name == len(name) * " ":
        if language == "English":
            return "Your child"
        elif language == "Hindi":
            return hindi_placeholder_name()
        elif language == "Gujarati":
            return gujarati_placeholder_name()
    else:
        return name
modules/upload_contacts_from_file.py
def assign_preg_signup(row, headers):
    row_entry = entry_or_empty_string(row=row, headers=headers).lower()
    if not row_entry:
        return False
    elif "pregnant" in row_entry:
        return True
    elif row_entry[0] == "1" or row_entry[0] == "t":
        return True
    else:
        return False
modules/upload_contacts_from_file.py
def parse_contact_time_references(row, headers):
    row_entry = check_all_headers(row=row, headers=headers)
    return datetime_string_mdy_to_datetime(row_entry) if row_entry else datetime.datetime.now().replace(tzinfo=timezone.get_default_timezone())
modules/upload_contacts_from_file.py
def filter_pregnancy_month(row, headers):
    month_of_pregnancy = entry_or_empty_string(row=row, headers=headers)
    if not month_of_pregnancy:
        return None
    elif month_of_pregnancy == "0":
        return 0
    month_of_pregnancy = re.sub("\D|0", "", str(month_of_pregnancy))
    return int(month_of_pregnancy[0]) if month_of_pregnancy else None
modules/upload_contacts_from_file.py
def assign_method_of_signup(row, headers, source):
    if source.lower() in ["maps", "hansa"]:
        return "Door to Door"
    elif source.lower() in ["wardha"]:
        return "Hospital"
    else:
        return entry_or_empty_string(row=row, headers=headers)
modules/upload_contacts_from_file.py
def previous_vaccination(row, headers):
    row_entry = check_all_headers(row=row, headers=headers)
    if row_entry is None or row_entry == "":
        return None
    
    if "y" == row_entry[0].lower():
        return True
    elif "n" == row_entry[0].lower():
        return False
    elif "y" in row_entry.lower():
        return True
    elif "n" in row_entry.lower():
        return False
    else:
        return None
modules/upload_contacts_from_file.py
def monthly_income(row, headers):
    row_entry = check_all_headers(row=row, headers=headers)
    return int(row_entry) if row_entry and not re.search("\D+", row_entry) else 999999
modules/upload_contacts_from_file.py
def assign_hospital_name(row, headers, method_of_signup, org_signup):
    return org_signup.capitalize() if method_of_signup == "Hospital" else entry_or_empty_string(row=row, headers=headers)
modules/i18n.py
def gujarati_placeholder_name():
    return u'\u0aa4\u0aae\u0abe\u0ab0\u0ac1\u0a82 \u0aac\u0abe\u0ab3\u0a95'
modules/upload_contacts_from_file.py
def check_all_headers(row, headers):
    for header in headers:
        if row.get(header):
            return row.get(header)
        
    for header in headers:
        matching_key = matching_permutation(row=row, header=header)
        if matching_key:
            return row.get(matching_key)

    return None
management/models.py
class Group(models.Model):
    """
    List of Pre-existing groups in Telerivet
    -----------------------
    Telerivet Blocked
    Cancelled Contacts
    Cancelled Contacts - English
    Cancelled Contacts - Hindi
    Cancelled Contacts - Text Sign Ups
    Cancelled Contacts - Text Sign Ups - English
    Cancelled Contacts - Text Sign Ups - Hindi
    Cancelled Contacts - Text Sign Ups - undefined
    Cancelled Contacts - undefined
    Everyone - English
    Everyone - Gujarati    Everyone - Hindi
    Everyone - Online Form
    Everyone - Text Default Time
    One Time Sign Up Message 06-02-17
    Online Form
    Online Form - English
    Online Form - English - ENG
    Online Form - English - ENG - Text Default Time
    Online Form - Gujarati
    Online Form - Gujarati - GUJ
    Online Form - Gujarati - GUJ - Text Default Time
    Online Form - Hindi
    Online Form - Hindi - HND
    Online Form - Hindi - HND - Text Default Time
    Sample Contacts
    Text Sign Ups
    Text Sign Ups - English
    Text Sign Ups - English - ENG
    Text Sign Ups - English - ENG - Text Default Time
    Text Sign Ups - Hindi
    """
    name = models.CharField(max_length=100, unique=True)
    contacts = models.ManyToManyField(Contact)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ('name',)
modules/upload_contacts_from_file.py
def assign_groups_to_contact(contact, groups_string):
    if not groups_string:
        return None
    for group_name in groups_string.split(", "):
        add_contact_to_group(contact, group_name)
modules/upload_contacts_from_file.py
def estimate_date_of_birth(month_of_pregnancy, date_of_sign_up):
    duration_of_pregnancy = 280 # mean number of days of a pregnancy
    if month_of_pregnancy is None or type(month_of_pregnancy) != int:
        return None

    conception_date = add_or_subtract_months(date=date_of_sign_up, num_of_months=-month_of_pregnancy)
    estimated_dob = add_or_subtract_days(date=conception_date, num_of_days=duration_of_pregnancy)
    return estimated_dob


Question: import os
import csv
import tempfile
from django.test import TestCase
from mock import patch
from freezegun import freeze_time
from datetime import datetime
from django.utils import timezone
from management.models import Contact, Group
from modules.utils import phone_number_is_valid
from modules.upload_contacts_from_file import csv_upload, make_contact_dict, assign_groups_to_contact, \
                                              previous_vaccination, monthly_income, parse_or_create_delay_num, \
                                              entered_date_string_to_date, parse_or_create_functional_dob, \
                                              parse_contact_time_references, assign_preg_signup, assign_preg_signup, \
                                              estimate_date_of_birth, filter_pregnancy_month, determine_language, \
                                              determine_mother_tongue, language_selector, replace_blank_name, \
                                              determine_name, matching_permutation, check_all_headers, \
                                              assign_org_signup, assign_method_of_signup, assign_hospital_name, \
                                              entry_or_empty_string, determine_date_of_birth, time_reference_or_none 
from modules.date_helper import add_or_subtract_days, add_or_subtract_months
from modules.i18n import hindi_placeholder_name, gujarati_placeholder_name
from dateutil.relativedelta import relativedelta
from six import u
        headers_mock.return_value = 200
        self.assertEqual("English", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = 300
        self.assertEqual("Gujarati", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "2"
        self.assertEqual("English", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "3"
        self.assertEqual("Gujarati", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "30"
        self.assertEqual("Gujarati", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "4"
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "7"
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = "None"
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = ""
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = " "
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))
        headers_mock.return_value = u"\\u0923\\u09a1"
        self.assertEqual("Hindi", determine_language(row=lan_row, headers=lan_pref))

    @patch("modules.upload_contacts_from_file.check_all_headers")
    def test_determine_mother_tongue(self, headers_mock):
        mother_options = ["Mother Tongue", "Mother Tongue Of Participant",
                            "Mother/Father Tongue 1.(Hindi, 2.English, 3.Other ", "Mother/Father Tongue"]
        mother_tongue_row = {'Mother Tongue': 'NONSENSE', 'Name': 'FakestNumber',
                        'Phone Number': '123456', 'Date of Birth': '2016-09-14'}
        headers_mock.return_value = "English"
        self.assertEqual("English", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "English--"
        self.assertEqual("English", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "Hindi"
        self.assertEqual("Hindi", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = " Hindi"
        self.assertEqual("Hindi", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "Other"
        self.assertEqual("Other", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "Other "
        self.assertEqual("Other", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "1"
        self.assertEqual("Hindi", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = 1
        self.assertEqual("Hindi", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = 200
        self.assertEqual("English", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = 300
        self.assertEqual("Other", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "2"
        self.assertEqual("English", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "20"
        self.assertEqual("English", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "3"
        self.assertEqual("Other", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "30"
        self.assertEqual("Other", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "4"
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "7"
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = "None"
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = ""
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = " "
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))
        headers_mock.return_value = u"\\u0923\\u09a1"
        self.assertEqual("", determine_mother_tongue(row=mother_tongue_row, headers=mother_options))

    def test_language_selector(self):
        self.assertIsNone(language_selector(language_input="", options=["Hindi", "English", "Other"],
                            default_option="Other", none_option=None))
        self.assertIsNone(language_selector(language_input=" ", options=["Hindi", "English", "Gujarati"],
                            default_option="Other", none_option=None))
        self.assertEqual("Hindi", language_selector(language_input=" ", options=["Hindi", "English", "Other"],
                            default_option="Other", none_option="Hindi"))
        self.assertEqual("Hindi", language_selector(language_input="", options=["Hindi", "English", "Other"],
                            default_option="Other", none_option="Hindi"))
        options_one = ["Hindi", "English", "Other"]
        options_two = ["Hindi", "English", "Gujarati"]
        options_three = ["Tiger", "Lion", "Cobra"]
        self.assertEqual(options_one[0], language_selector(language_input=options_one[0], options=options_one,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_one[1], language_selector(language_input=options_one[1], options=options_one,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_one[2], language_selector(language_input=options_one[2], options=options_one,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[2], language_selector(language_input=options_two[2], options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_three[2], language_selector(language_input=options_three[2], options=options_three,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_one[2], language_selector(language_input=" " + options_one[2] + " ", options=options_one,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[0], language_selector(language_input="1", options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[1], language_selector(language_input="2", options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[1], language_selector(language_input="20", options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[2], language_selector(language_input="3", options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[2], language_selector(language_input=3, options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual(options_two[1], language_selector(language_input=20, options=options_two,
                            default_option="Other", none_option="Hindi"))
        self.assertEqual("Stuff", language_selector(language_input="7", options=options_two,
                            default_option="Stuff", none_option="Hindi"))
        self.assertEqual("Stuff", language_selector(language_input="dfsadfasdfp", options=options_two,
                            default_option="Stuff", none_option="Hindi"))
        self.assertEqual("More stuff", language_selector(language_input=u"\\u0923\\u09a1", options=options_two,
                            default_option="More stuff", none_option="Hindi"))

    def test_replace_blank_name(self):
        self.assertEqual("Your child", replace_blank_name(name=None, language="English"))
        self.assertEqual("Your child", replace_blank_name(name="", language="English"))
        self.assertEqual("Your child", replace_blank_name(name=" ", language="English"))
        self.assertEqual("Your child", replace_blank_name(name="     ", language="English"))
        self.assertEqual("Harvey", replace_blank_name(name="Harvey", language="English"))
        self.assertEqual(u"\u0906\u092a\u0915\u093e", replace_blank_name(name=u"\u0906\u092a\u0915\u093e", language="English"))

Answer:         self.assertEqual(hindi_placeholder_name(), replace_blank_name(name=None, language="Hindi"))