예제 #1
0
def test_step_vr3_with_prev_address_and_mail_addr(app, db_session, client):
    form_payload3 = {
        'addr': "707 Vermont St",
        'unit': "Room A",
        'city': "Lawrence",
        'state': "FLORIDA",
        'zip': '66044',
        'has_prev_addr': True,
        'prev_addr': "707 Vermont St",
        'prev_unit': "Room B",
        'prev_city': "Lawrence",
        'prev_state': "FLORIDA",
        'prev_zip': '66044',
        'has_mail_addr': True,
        'mail_addr': "707 Vermont St",
        'mail_unit': "Room C",
        'mail_city': "Lawrence",
        'mail_state': "FLORIDA",
        'mail_zip': '66044',
    }
    step = Step_VR_3(form_payload3)
    step.run()
    assert step.is_complete == True
    assert step.next_step == 'Step_VR_4'
    assert 'current_address' in step.validated_addresses
    assert step.validated_addresses['current_address']['unit'] == 'RM A'
    assert 'prev_addr' in step.validated_addresses
    assert step.validated_addresses['prev_addr']['unit'] == 'RM B'
    assert step.addr_lookup_complete == True
    assert 'mail_addr' in step.validated_addresses
    assert step.validated_addresses['mail_addr']['unit'] == 'RM C'
예제 #2
0
def test_step_vr3_is_complete_false_with_missing_arguments(app, db_session, client):
    """
        Verify that this registrant is not ready to move on to vr3 next step.
    """
    form_payload = {}
    step = Step_VR_3(form_payload)
    assert step.run() == False
    assert step.is_complete == False
    assert step.next_step == None
예제 #3
0
def test_step_vr3_is_complete_false_with_bad_address(app, db_session, client):
    """
        Verify that this registrant is not ready to move on to the next step and next step is VR 4.
    """
    form_payload = {
        'addr': "123 Fake St",
        'city': "Fake",
        'state': "NA",
        'zip': '66044',
    }
    step = Step_VR_3(form_payload)
    step.run()
    assert step.validated_addresses == False
    assert step.is_complete == True
    assert step.addr_lookup_complete == True
예제 #4
0
def test_step_vr3_is_complete_true_with_one_address(app, db_session, client):
    """
        Verify that this registrant is ready to move on to the next step and next step is VR 4.
    """
    form_payload = {
        'addr': "707 Vermont St",
        'unit': "Room A",
        'city': "Lawrence",
        'state': "FLORIDA",
        'zip': '66044'
    }
    step = Step_VR_3(form_payload)
    step.run()
    assert step.run() == True
    assert step.is_complete == True
    assert 'current_address' in step.validated_addresses
    assert step.validated_addresses['current_address']['state'] == 'KS'
    assert step.addr_lookup_complete == True
    assert step.next_step == 'Step_VR_4'
예제 #5
0
def vr3_address():
    form = FormVR3(
        addr=g.registrant.registration_value.get('addr', ''),
        unit=g.registrant.registration_value.get('unit', ''),
        city=g.registrant.registration_value.get('city', ''),
        state=g.registrant.registration_value.get('state', 'FLORIDA'),
        zip=g.registrant.registration_value.get('zip', ''),
        has_prev_addr=g.registrant.registration_value.get('has_prev_addr'),
        prev_addr=g.registrant.registration_value.get('prev_addr', ''),
        prev_unit=g.registrant.registration_value.get('prev_unit', ''),
        prev_city=g.registrant.registration_value.get('prev_city', ''),
        prev_state=g.registrant.registration_value.get('prev_state', ''),
        prev_zip=g.registrant.registration_value.get('prev_zip', ''),
        has_mail_addr=g.registrant.registration_value.get('has_mail_addr'),
        mail_addr=g.registrant.registration_value.get('mail_addr', ''),
        mail_unit=g.registrant.registration_value.get('mail_unit', ''),
        mail_city=g.registrant.registration_value.get('mail_city', ''),
        mail_state=g.registrant.registration_value.get('mail_state', ''),
        mail_zip=g.registrant.registration_value.get('mail_zip', ''),
    )
    if request.method == "POST" and form.validate_on_submit():
        step = Step_VR_3(form.data)
        step.run()
        update_data = form.data
        update_data['validated_addresses'] = step.validated_addresses
        g.registrant.update(update_data)
        g.registrant.addr_lookup_complete = step.addr_lookup_complete

        # override initial county guess with best guess based on validated address
        zip5 = g.registrant.best_zip5()
        county = ZIPCode.guess_county(zip5)
        current_app.logger.info("Lookup county %s based on ZIP5 %s" %
                                (county, zip5))
        g.registrant.county = county

        db.session.commit()
        session_manager = SessionManager(g.registrant, step)
        return redirect(session_manager.get_redirect_url())
    return render_template('vr/address.html', form=form)
예제 #6
0
def test_step_vr3_with_bad_prev_address(app, db_session, client):
    form_payload = {
        'addr': "707 Vermont St",
        'unit': "Room A",
        'city': "Lawrence",
        'state': "FLORIDA",
        'zip': '66044',
        'has_prev_addr': True,
        'prev_addr': "foo",
        'prev_unit': "bar",
        'prev_city': "baz",
        'prev_state': "nitro",
        'prev_zip': '',
    }
    step = Step_VR_3(form_payload)
    step.run()
    assert step.is_complete == True
    assert step.next_step == 'Step_VR_4'
    assert 'current_address' in step.validated_addresses
    assert step.validated_addresses['current_address']['unit'] == 'RM A'
    assert 'prev_addr' in step.validated_addresses
    assert 'error' in step.validated_addresses['prev_addr']