def test_affiliate_full_state(): """This populates the full_state_name field""" affiliate = affiliate_factory(state='VA') assert affiliate.full_state_name == "Virginia" affiliate = affiliate_factory(state='va') assert affiliate.full_state_name == "Virginia" affiliate = affiliate_factory(state='NY') assert affiliate.full_state_name == "New York"
def test_search_in_network(empty_partner, girl_scouts, boy_scouts, girls_and_boys_club): affiliate = affiliate_factory() girl_scouts.network_use.add(affiliate) girls_and_boys_club.network_use.add(affiliate) assert girl_scouts.network_use.all().exists() assert girls_and_boys_club.network_use.all().exists() assert Partner.partners.filter(network_use=True).exists() form = PartnerSearchForm(data={'use_in_network': True}) assert form.is_valid() assert {girl_scouts, girls_and_boys_club } == set(Partner.partners.search(**form.cleaned_data)) form = PartnerSearchForm(data={'use_in_network': False}) assert form.is_valid() assert {boy_scouts, empty_partner} == set(Partner.partners.search(**form.cleaned_data)) form = PartnerSearchForm(data={'use_in_network': None}) assert form.is_valid() assert {empty_partner, girl_scouts, boy_scouts, girls_and_boys_club } == set(Partner.partners.search(**form.cleaned_data)) # noqa
def test_affiliate_eoy_aggregation_methods(current_eoy): affiliate = affiliate_factory() school_data_1 = school_data_factory( affiliate=affiliate, year=current_eoy, students_served_frpl=1, students_served_ell=1, students_served_foster=1, students_served_homeless=1, students_served_lgbt=1, students_served_pregnant_parenting=1, students_served_special_education=1, students_served_substance_abuse=1, students_served_adjudicated_youth=1, students_served_child_of_military=1, students_served_gang=1, students_served_incarcerated_parent=1, students_total=340, ) school_data_factory( affiliate=affiliate, year=current_eoy, students_served_frpl=2, students_served_ell=2, students_served_foster=2, students_served_homeless=2, students_served_lgbt=2, students_served_pregnant_parenting=2, students_served_special_education=2, students_served_substance_abuse=2, students_served_adjudicated_youth=2, students_served_child_of_military=2, students_served_gang=2, students_served_incarcerated_parent=2, students_total=200, ) affiliate_data = AffiliateEOYData.objects.get(pk=school_data_1.affiliate_data.pk) assert 3 == affiliate_data.total_students_frpl() assert 3 == affiliate_data.total_students_adjudicated_youth() assert 3 == affiliate_data.total_students_child_of_military() assert 3 == affiliate_data.total_students_ell() assert 3 == affiliate_data.total_students_foster() assert 3 == affiliate_data.total_students_gang() assert 3 == affiliate_data.total_students_homeless() assert 3 == affiliate_data.total_students_incarcerated_parent() assert 3 == affiliate_data.total_students_lgbt() assert 3 == affiliate_data.total_students_pregnant_parenting() assert 3 == affiliate_data.total_students_special_education() assert 3 == affiliate_data.total_students_substance_abuse() assert 540 == affiliate_data.total_students_served()
def test_gender_data(current_eoy): affiliate = affiliate_factory() school_data_1 = school_data_factory( affiliate=affiliate, year=current_eoy, name="School 1", students_female_hispanic=4, ) school_data_2 = school_data_factory( affiliate=affiliate, year=current_eoy, name="School 2", students_male_hispanic=1, students_female_hispanic=1, students_male_asian=1, ) affiliate_data = AffiliateEOYData.objects.get(pk=school_data_2.affiliate_data.pk) assert affiliate_data == school_data_1.affiliate_data == school_data_2.affiliate_data assert affiliate_data.search_students_female == 5 assert affiliate_data.search_students_male == 2 assert set(affiliate_data.search_gender) == set(choices.Gender.all_names())
def acme_affiliate(): yield affiliate_factory(name="Acme", state="TX", affiliate_location=AffiliateLocation.S.name)
def local_affiliate(): yield affiliate_factory(name="Local Affiliate", state="VA", affiliate_location=AffiliateLocation.R.name)