def test_fill_fee_waiver_details_works(): v = hp.HPActionVariables(sue_for_repairs_tf=True) fwd = FeeWaiverDetails( receives_public_assistance=True, rent_amount=Decimal('5.00'), income_amount_monthly=Decimal('11.50'), income_src_employment=True, income_src_hra=True, expense_utilities=Decimal('1.50'), expense_cable=Decimal('2.50'), expense_phone=Decimal('0.25'), asked_before=False, ) fill_fee_waiver_details(v, fwd) assert v.cause_of_action_description_te == "Landlord has failed to do repairs" assert v.request_fee_waiver_tf is True assert v.tenant_receives_public_assistance_tf is True assert v.tenant_income_nu == 11.50 assert v.tenant_income_source_te == 'Employment, HRA' assert v.tenant_monthly_rent_nu == 5 assert v.tenant_monthly_exp_utilities_nu == 1.50 assert v.tenant_monthly_exp_other_nu == 2.75 assert v.previous_application_tf is False assert v.reason_for_further_application_te is None fwd.asked_before = True v = hp.HPActionVariables(sue_for_repairs_tf=True, sue_for_harassment_tf=True) fill_fee_waiver_details(v, fwd) assert v.previous_application_tf is True assert v.reason_for_further_application_te == "economic hardship" assert v.cause_of_action_description_te == \ "Landlord has failed to do repairs and engaged in harassing behaviors"
def test_sue_for_harassment_works(): h = HPActionDetailsFactory.build(sue_for_harassment=True) v = hp.HPActionVariables() fill_hp_action_details(v, h) assert v.sue_for_harassment_tf is True h.sue_for_harassment = None v = hp.HPActionVariables() fill_hp_action_details(v, h) assert v.problem_is_urgent_tf is None
def test_it_works_with_children_and_other_stuff(): v = hp.HPActionVariables() v.access_person_te = "Boop Jones" v.action_type_ms = [hp.ActionTypeMS.REPAIRS] child = hp.TenantChild(tenant_child_name_te='Bap Jones') v.tenant_child_list.append(child) ensure_answer_set( v, """\ <?xml version="1.0" ?> <AnswerSet title="New Answer File" version="1.1"> <Answer name="Access person TE"> <TextValue>Boop Jones</TextValue> </Answer> <Answer name="Action type MS"> <MCValue> <SelValue>Repairs</SelValue> </MCValue> </Answer> <Answer name="Tenant child name TE"> <RptValue> <TextValue>Bap Jones</TextValue> </RptValue> </Answer> <Answer name="Tenant child DOB"> <RptValue> <DateValue unans="true"/> </RptValue> </Answer> </AnswerSet> """)
def test_it_works_with_complaints(): v = hp.HPActionVariables() complaint = hp.TenantComplaints( area_complained_of_mc=hp.AreaComplainedOfMC.PUBLIC_AREA) v.tenant_complaints_list.append(complaint) ensure_answer_set( v, """\ <?xml version="1.0" ?> <AnswerSet title="New Answer File" version="1.1"> <Answer name="Area complained of MC"> <RptValue> <MCValue> <SelValue>Public area</SelValue> </MCValue> </RptValue> </Answer> <Answer name="Which room MC"> <RptValue> <MCValue unans="true"/> </RptValue> </Answer> <Answer name="Conditions complained of TE"> <RptValue> <TextValue unans="true"/> </RptValue> </Answer> </AnswerSet> """)
def test_fill_prior_repairs_and_harassment_mcs_works(kwargs, repairs, harassment): pc = PriorCaseFactory.build(**kwargs) v = hp.HPActionVariables() fill_prior_repairs_and_harassment_mcs(v, [pc]) assert v.prior_repairs_case_mc == getattr(hp.PriorRepairsCaseMC, repairs) assert v.prior_harassment_case_mc == getattr(hp.PriorHarassmentCaseMC, harassment)
def test_fill_prior_cases_works(db): pc = PriorCaseFactory() v = hp.HPActionVariables() fill_prior_cases(v, pc.user) assert v.prior_repairs_case_mc == hp.PriorRepairsCaseMC.YES assert v.prior_harassment_case_mc == hp.PriorHarassmentCaseMC.NO assert v.prior_relief_sought_case_numbers_and_dates_te == \ "repairs case #123456789 on 2018-01-03"
def test_problem_is_urgent_tf_works(): h = HPActionDetailsFactory.build(urgent_and_dangerous=True) v = hp.HPActionVariables() fill_hp_action_details(v, h) assert v.problem_is_urgent_tf is True h.urgent_and_dangerous = False fill_hp_action_details(v, h) assert v.problem_is_urgent_tf is False
def test_fill_tenant_children_works_when_there_are_children(): v = hp.HPActionVariables() child = TenantChildFactory.build() fill_tenant_children(v, [child]) assert v.tenant_children_under_6_nu == 1 assert len(v.tenant_child_list) == 1 hp_child = v.tenant_child_list[0] assert hp_child.tenant_child_name_te == child.name assert hp_child.tenant_child_dob == child.dob
def test_problem_is_urgent_tf_works(): h = HPActionDetailsFactory.build(urgent_and_dangerous=True) v = hp.HPActionVariables() fill_hp_action_details(v, h) # In practice, the city *always* wants this to be false, so we're # testing to make sure our code disregards what the user answered. assert v.problem_is_urgent_tf is False h.urgent_and_dangerous = False fill_hp_action_details(v, h) assert v.problem_is_urgent_tf is False
def test_fill_nycha_info_works(db, loaded_nycha_csv_data): oinfo = OnboardingInfoFactory(pad_bbl='') v = hp.HPActionVariables() fill_nycha_info(v, oinfo.user) assert v.user_is_nycha_tf is None oinfo.pad_bbl = '1234567890' fill_nycha_info(v, oinfo.user) assert v.user_is_nycha_tf is False oinfo.pad_bbl = '2022150116' fill_nycha_info(v, oinfo.user) assert v.user_is_nycha_tf is True
def test_fill_harassment_details_works(): h = HarassmentDetailsFactory.build( two_or_less_apartments_in_building=False, more_than_one_family_per_apartment=False, alleg_sued=True, harassment_details="Blarg") v = hp.HPActionVariables() fill_harassment_details(v, h) assert v.more_than_2_apartments_in_building_tf is True assert v.more_than_one_family_per_apartment_tf is False assert v.harassment_sued_tf is True assert v.harassment_stopped_service_tf is False assert v.harassment_details_te == 'Blarg' assert v.prior_relief_sought_case_numbers_and_dates_te is None
def test_hp_action_variables_has_harassment_allegation_attr( enum_name, attr_name): v = hp.HPActionVariables() assert hasattr(v, attr_name)
def test_fill_tenant_children_works_when_there_are_no_children(): v = hp.HPActionVariables() fill_tenant_children(v, []) assert v.tenant_children_under_6_nu == 0 assert v.tenant_child_list == []