Exemple #1
0
def test_from_user_works_with_onboarded_user():
    info = OnboardingInfoFactory(can_we_sms=True)
    fields = Fields.from_user(info.user)
    assert fields.onboarding_info__can_we_sms is True
    assert fields.onboarding_info__address_for_mailing == \
        "150 court street\nApartment 2\nBrooklyn, NY"
    assert fields.onboarding_info__lease_type == 'RENT_STABILIZED'

    info.can_we_sms = False
    info.save()
    fields = Fields.from_user(info.user)
    assert fields.onboarding_info__can_we_sms is False
Exemple #2
0
def test_from_user_works_with_letter_request():
    lr = LetterRequestFactory()
    fields = Fields.from_user(lr.user)
    assert fields.letter_request__will_we_mail is True
    assert fields.letter_request__created_at == datetime.datetime.utcnow().date().isoformat()
    assert strip_locale(fields.letter_request__admin_pdf_url) == \
        f'https://example.com/loc/admin/{lr.user.pk}/letter.pdf'
Exemple #3
0
def test_from_user_works_with_partial_hp_action():
    details = HPActionDetailsFactory(sue_for_repairs=True,
                                     sue_for_harassment=True)
    fields = Fields.from_user(details.user)
    assert fields.hp_action_details__latest_documents__created_at is None
    assert fields.hp_action_details__sue_for_repairs is True
    assert fields.hp_action_details__sue_for_harassment is True
Exemple #4
0
def test_from_user_works_with_letter_request():
    lr = LetterRequestFactory(letter_sent_at=make_aware(
        datetime.datetime(2018, 5, 6)),
                              rejection_reason='INCRIMINATING',
                              tracking_number='boop')
    fields = Fields.from_user(lr.user)
    assert fields.letter_request__will_we_mail is True
    assert fields.letter_request__created_at == datetime.datetime.utcnow(
    ).date().isoformat()
    assert strip_locale(fields.letter_request__admin_pdf_url) == \
        f'https://example.com/loc/admin/{lr.user.pk}/letter.pdf'
    assert fields.letter_request__letter_sent_at == '2018-05-06'
    assert fields.letter_request__rejection_reason == 'INCRIMINATING'
    assert fields.letter_request__tracking_number == 'boop'
Exemple #5
0
def test_from_user_works_with_minimal_user():
    user = UserFactory(
        phone_number='5551234567',
        full_name='Bobby Denver'
    )
    fields = Fields.from_user(user)
    assert fields.pk == user.pk
    assert fields.first_name == 'Bobby'
    assert fields.last_name == 'Denver'
    assert fields.admin_url == f'https://example.com/admin/users/justfixuser/{user.pk}/change/'
    assert fields.phone_number == '5551234567'
    assert fields.onboarding_info__can_we_sms is False
    assert fields.onboarding_info__lease_type == ''
    assert fields.letter_request__created_at is None
    assert fields.landlord_details__name == ''
    assert fields.landlord_details__address == ''
    assert fields.letter_request__will_we_mail is False