def test_it_raises_err_when_letter_already_sent(self): letter = LetterFactory(user=self.user) UpcomingLetterRentPeriodFactory( user=self.user, rent_period=letter.rent_periods.all()[0]) OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You have already sent a letter for one of the rent periods!")
def test_it_shows_discontinued_message(self, use_evictionfree_site, settings): settings.IS_EFNY_SUSPENDED = True self.create_landlord_details() OnboardingInfoFactory(user=self.user) HardshipDeclarationDetailsFactory(user=self.user) with freezegun.freeze_time("2021-01-26"): assert self.execute()["errors"] == one_field_err( "This tool has been suspended! Please reload the page for more details." )
def test_email_letter_fails_when_letter_not_finished( self, db, graphql_client, mailoutbox): graphql_client.request.user = UserFactory() result = graphql_client.execute(self.QUERY)["data"]["emailLetter"] assert result == { "errors": one_field_err("You have not completed a Letter of Complaint!"), "recipients": None, } assert len(mailoutbox) == 0
def test_it_errors_on_nyc_addresses(self, settings, requests_mock, monkeypatch): from norent import schema monkeypatch.setattr(schema, "is_lnglat_in_nyc", lambda point: True) settings.MAPBOX_ACCESS_TOKEN = "blah" self.set_prior_info() mock_brl_results("150 court st, Brooklyn, NY 12345", requests_mock) output = self.execute() assert output["errors"] == one_field_err( "Your address appears to be within New York City. Please go back and enter " '"New York City" as your city.')
def test_it_raises_error_when_nothing_is_selected_after_deletion(self): ci = CustomIssue(user=self.user, area=ISSUE_AREA_CHOICES.HOME, description="hi") ci.save() input = { "issues": [], "customHomeIssues": [{ "description": "", "DELETE": True, "id": ci.id }], } result = self.execute(input) assert result["errors"] == one_field_err( "Please choose at least one option.") # Now add a regular issue, it should work and delete the custom one. input["issues"] = ["HOME__NO_HEAT"] assert self.execute(input)["errors"] == [] assert CustomIssue.objects.filter(pk=ci.id).first() is None
def test_it_raises_err_when_no_rent_periods_are_chosen(self): OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You have not chosen any rent periods!")
def test_it_raises_err_when_no_onboarding_info_exists(self): assert self.execute()["errors"] == one_field_err( "You haven't provided any account details yet!")
def test_it_raises_err_when_no_onboarding_info_exists(self): UpcomingLetterRentPeriodFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You haven't provided any account details yet!")
def test_unimpersonate_raises_error_if_not_impersonating(self): res = self.exec_graphql(UNIMPERSONATE_QUERY) assert res["data"]["unimpersonate"] == { "errors": one_field_err("You are not currently impersonating another user."), "session": None, }
def test_it_raises_err_when_user_is_outside_ny(self): self.create_landlord_details() OnboardingInfoFactory(user=self.user, state="CA") assert self.execute()["errors"] == one_field_err( "You must be in the state of New York to use this tool!")
def test_it_raises_err_when_used_on_wrong_site(self): self.create_landlord_details() OnboardingInfoFactory(user=self.user) HardshipDeclarationDetailsFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "This form can only be used from the Eviction Free NY site.")
def ensure_error(self, message): assert self.execute()["errors"] == one_field_err(message)
def test_it_requires_at_least_one_checkbox(self): res = self.execute({}) assert res["errors"] == one_field_err( "Please choose at least one option.")
def test_it_raises_error_when_nothing_is_selected(self): result = self.execute({"issues": [], "customHomeIssues": []}) assert result["errors"] == one_field_err( "Please choose at least one option.")
def test_it_raises_err_when_declaration_already_sent(self): SubmittedHardshipDeclarationFactory(user=self.user) OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You have already sent a hardship declaration form!")
def test_it_requires_login(self): self.graphql_client.request.user = AnonymousUser() assert self.execute()["errors"] == one_field_err( "You do not have permission to use this form!")
def test_it_raises_err_when_used_on_wrong_site(self): OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "This form can only be used from the LA Letter Builder site.")
def test_it_raises_err_when_used_on_wrong_site(self): UpcomingLetterRentPeriodFactory(user=self.user) self.create_landlord_details() OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "This form can only be used from the NoRent site.")
def test_it_requires_auth(self, graphql_client): result = execute_genpdf_mutation(graphql_client) assert result["errors"] == one_field_err( "You do not have permission to use this form!")
def test_it_raises_err_when_no_landlord_details_exist(self): OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You haven't provided any landlord details yet!")
def test_tenant_children_mutation_requires_login(db, graphql_client): result = execute_tenant_children_mutation(graphql_client, []) assert result["errors"] == one_field_err( "You do not have permission to use this form!")
def test_it_raises_err_when_no_hardship_declaration_details_exist(self): self.create_landlord_details() OnboardingInfoFactory(user=self.user) assert self.execute()["errors"] == one_field_err( "You haven't provided details for your hardship declaration form yet!" )