Exemplo n.º 1
0
 def test_returns_empty_instance_if_lookup_fails(self, requests_mock):
     mock_lookup_failure(requests_mock)
     oi = OnboardingInfoFactory()
     info = LandlordDetails.create_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
Exemplo n.º 2
0
 def test_returns_filled_instance_if_lookup_succeeds(
         self, requests_mock, nycdb):
     mock_lookup_success(requests_mock, nycdb)
     oi = OnboardingInfoFactory()
     info = LandlordDetails.create_lookup_for_user(oi.user)
     assert info.name == 'BOOP JONES'
     assert info.address == "124 99TH STREET\nBrooklyn, NY 11999"
     assert info.lookup_date is not None
     assert info.is_looked_up is True
Exemplo n.º 3
0
 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"
Exemplo n.º 4
0
def create_user_with_all_info(issues=True, landlord=True, access_dates=True):
    info = OnboardingInfoFactory(user__full_name="Bobby Denver",
                                 address="1 Times Square",
                                 borough="MANHATTAN",
                                 apt_number="301",
                                 zipcode="11201",
                                 can_we_sms=True,
                                 has_called_311=False)
    user = info.user
    if issues:
        Issue.objects.set_area_issues_for_user(user, 'HOME', ['HOME__MICE'])
    if landlord:
        ld = LandlordDetails(user=user,
                             name='Landlordo Calrissian',
                             address='1 Cloud City\nBespin')
        ld.save()
    if access_dates:
        AccessDate.objects.set_for_user(user, [datetime.date(2018, 2, 1)])
    return user
Exemplo n.º 5
0
def test_landlord_details_address_lines_for_mailing_works():
    ld = LandlordDetails()
    assert ld.address_lines_for_mailing == []

    ld.address = "1 Cloud City\nBespin"
    assert ld.address_lines_for_mailing == ["1 Cloud City", "Bespin"]

    # Ensure it prefers granular details.
    ld.primary_line = "1 Cloud City"
    ld.city = "Bespin"
    ld.state = "OH"
    ld.zip_code = "43220"
    assert ld.address_lines_for_mailing == [
        "1 Cloud City",
        "Bespin, OH 43220",
    ]
Exemplo n.º 6
0
def test_get_landlord_details_works():
    user = UserFactory()
    assert get_landlord_details(user).name == ''

    user.landlord_details = LandlordDetails(name="Blarg")
    assert get_landlord_details(user).name == 'Blarg'
Exemplo n.º 7
0
 def test_returns_none_if_address_info_is_not_available(self):
     user = UserFactory.build()
     assert LandlordDetails.create_lookup_for_user(user) is None
Exemplo n.º 8
0
def test_landlord_details_address_lines_for_mailing_works():
    ld = LandlordDetails()
    assert ld.address_lines_for_mailing == []

    ld.address = '1 Cloud City\nBespin'
    assert ld.address_lines_for_mailing == ['1 Cloud City', 'Bespin']
Exemplo n.º 9
0
def get_landlord_details(user) -> LandlordDetails:
    if hasattr(user, 'landlord_details'):
        return user.landlord_details
    return LandlordDetails()
Exemplo n.º 10
0
def test_landlord_details_formatted_phone_number_works():
    assert LandlordDetails().formatted_phone_number() == ""
    assert LandlordDetails(
        phone_number="5551234567").formatted_phone_number() == "(555) 123-4567"