def test_returns_empty_instance_if_lookup_fails(self, requests_mock): mock_lookup_failure(requests_mock) oi = OnboardingInfoFactory() info = LandlordDetails.create_or_update_lookup_for_user(oi.user) assert info.name == "" assert info.address == "" assert info.lookup_date is not None assert info.is_looked_up is False
def test_it_updates_existing_ll_details(self, requests_mock, nycdb): ld = LandlordDetailsV2Factory() assert ld.name == "Landlordo Calrissian" mock_lookup_success(requests_mock, nycdb) OnboardingInfoFactory(user=ld.user) info = LandlordDetails.create_or_update_lookup_for_user(ld.user) assert info.pk == ld.pk ld.refresh_from_db() assert ld.name == "BOOP JONES"
def test_returns_filled_instance_if_lookup_succeeds( self, requests_mock, nycdb): mock_lookup_success(requests_mock, nycdb) oi = OnboardingInfoFactory() info = LandlordDetails.create_or_update_lookup_for_user(oi.user) assert info.name == "BOOP JONES" assert info.address == "124 99TH STREET\nBrooklyn, NY 11999" assert info.primary_line == "124 99TH STREET" assert info.city == "Brooklyn" assert info.state == "NY" assert info.zip_code == "11999" assert info.lookup_date is not None assert info.is_looked_up is True
def test_returns_none_if_address_info_is_not_available(self): user = UserFactory.build() assert LandlordDetails.create_or_update_lookup_for_user(user) is None