def test_user_to_hpactionvars_requests_fee_waiver_only_if_model_exists(db): user = UserFactory(full_name="Boop Jones") v = user_to_hpactionvars(user) assert v.request_fee_waiver_tf is None FeeWaiverDetails(user=user) v = user_to_hpactionvars(user) assert v.request_fee_waiver_tf is True
def test_user_to_hpactionvars_populates_harassment_only_if_user_wants_it(db): har = HarassmentDetailsFactory(two_or_less_apartments_in_building=False) PriorCaseFactory(user=har.user) v = user_to_hpactionvars(har.user) assert v.sue_for_harassment_tf is None assert v.more_than_2_apartments_in_building_tf is None assert v.prior_repairs_case_mc is None HPActionDetailsFactory(sue_for_harassment=True, user=har.user) v = user_to_hpactionvars(har.user) assert v.sue_for_harassment_tf is True assert v.more_than_2_apartments_in_building_tf is True assert v.prior_repairs_case_mc == hp.PriorRepairsCaseMC.YES
def handle(self, *args, **options) -> None: kind: str = options["kind"] if kind not in HP_ACTION_CHOICES.choices_dict: raise CommandError(f"Invalid kind: {kind}") if not settings.HP_ACTION_CUSTOMER_KEY: raise CommandError("HP_ACTION_CUSTOMER_KEY is not defined!") user = JustfixUser.objects.get(username=options["username"]) token = UploadToken.objects.create_for_user(user, kind) token.full_clean() self.stdout.write("Created upload token. Sending SOAP request...\n") xml_input_file: Optional[str] = options["xml_input_file"] if xml_input_file: hdinfo: lhiapi.HDInfo = self.load_xml_input_file(xml_input_file) else: hdinfo = user_to_hpactionvars(user, kind) docs = lhiapi.get_answers_and_documents(token, hdinfo) if docs is None: raise CommandError( f"An error occurred when generating the documents.") self.stdout.write("Successfully received HP Action documents.\n") if options["extract_files"]: self.extract_files(docs, basename=options["extract_basename"])
def test_user_to_hpactionvars_populates_onboarding_info(db): oi = OnboardingInfoFactory.create(apt_number='2B', borough='BROOKLYN') v = user_to_hpactionvars(oi.user) assert v.tenant_address_apt_no_te == '2B' assert v.court_county_mc == hp.CourtCountyMC.KINGS assert v.court_location_mc == hp.CourtLocationMC.KINGS_COUNTY v.to_answer_set()
def test_user_to_hpactionvars_sues_only_if_user_wants_to(db): user = UserFactory(full_name="Boop Jones") v = user_to_hpactionvars(user) assert v.sue_for_harassment_tf is None assert v.sue_for_repairs_tf is None hpd = HPActionDetailsFactory(user=user, sue_for_harassment=True, sue_for_repairs=False) v = user_to_hpactionvars(user) assert v.sue_for_harassment_tf is True assert v.sue_for_repairs_tf is False hpd.sue_for_repairs = True hpd.save() v = user_to_hpactionvars(user) assert v.sue_for_repairs_tf is True
def test_user_to_hpactionvars_populates_tiny_ll_info_from_nycdb( db, nycdb, use_bin): tiny = nycdb.load_hpd_registration('tiny-landlord.json') oinfo = OnboardingInfoFactory(**onboarding_info_pad_kwarg(tiny, use_bin)) v = user_to_hpactionvars(oinfo.user) assert v.landlord_entity_name_te == "BOOP JONES" assert v.landlord_entity_or_individual_mc == hp.LandlordEntityOrIndividualMC.INDIVIDUAL v.to_answer_set()
def test_user_to_hpactionvars_populates_med_ll_info_from_nycdb( db, nycdb, use_bin): med = nycdb.load_hpd_registration('medium-landlord.json') oinfo = OnboardingInfoFactory(**onboarding_info_pad_kwarg(med, use_bin)) v = user_to_hpactionvars(oinfo.user) assert v.landlord_entity_name_te == "LANDLORDO CALRISSIAN" assert v.landlord_entity_or_individual_mc == hp.LandlordEntityOrIndividualMC.COMPANY assert v.landlord_address_street_te == "9 BEAN CENTER DRIVE #40" llstate = v.landlord_address_state_mc assert llstate and llstate.value == "NJ" assert v.management_company_name_te == "FUNKY APARTMENT MANAGEMENT" assert v.management_company_address_street_te == "900 EAST 25TH STREET #2" v.to_answer_set()
def test_user_to_hpactionvars_populates_issues(db): user = UserFactory() Issue.objects.set_area_issues_for_user(user, ISSUE_AREA_CHOICES.KITCHEN, [ISSUE_CHOICES.KITCHEN__MOLD]) CustomIssue.objects.set_for_user(user, ISSUE_AREA_CHOICES.PUBLIC_AREAS, 'Lobby is consumed by darkness') v = user_to_hpactionvars(user) assert len(v.tenant_complaints_list) == 2 first, second = v.tenant_complaints_list assert first.area_complained_of_mc == hp.AreaComplainedOfMC.MY_APARTMENT assert first.which_room_mc.value == "Kitchen" # type: ignore assert first.conditions_complained_of_te == "Mold on walls" assert second.area_complained_of_mc == hp.AreaComplainedOfMC.PUBLIC_AREA assert second.which_room_mc.value == "Public areas" # type: ignore assert second.conditions_complained_of_te == "Lobby is consumed by darkness" v.to_answer_set()
def handle(self, *args, **options) -> None: if not settings.HP_ACTION_CUSTOMER_KEY: raise CommandError('HP_ACTION_CUSTOMER_KEY is not defined!') user = JustfixUser.objects.get(username=options['username']) token = UploadToken.objects.create_for_user(user) self.stdout.write('Created upload token. Sending SOAP request...\n') xml_input_file: Optional[str] = options['xml_input_file'] if xml_input_file: hdinfo: lhiapi.HDInfo = self.load_xml_input_file(xml_input_file) else: hdinfo = user_to_hpactionvars(user) docs = lhiapi.get_answers_and_documents(token, hdinfo) if docs is None: raise CommandError(f"An error occurred when generating the documents.") self.stdout.write("Successfully received HP Action documents.\n") if options['extract_files']: self.extract_files(docs, basename=options['extract_basename'])
def test_user_to_hpactionvars_populates_basic_landlord_info(db): ld = LandlordDetailsFactory(name="Landlordo Calrissian") v = user_to_hpactionvars(ld.user) assert v.landlord_entity_name_te == "Landlordo Calrissian" v.to_answer_set()
def test_user_to_hpactionvars_populates_basic_info(db): user = UserFactory(full_name="Boop Jones") v = user_to_hpactionvars(user) assert v.tenant_name_first_te == "Boop" assert v.tenant_name_last_te == "Jones" v.to_answer_set()