def test_an_applicant_that_paid_more_than_24hrs_ago_cannot_schedule(client, monkeypatch):
    iso_format = "%Y-%m-%d"
    date_served = (datetime.datetime.now() - datetime.timedelta(days=5)).strftime(iso_format)
    payment_date = (datetime.datetime.now() - datetime.timedelta(days=2)).strftime(iso_format)

    responses.add(responses.GET,
                  '{}/{}/status/{}'.format(Config.VIPS_API_ROOT_URL, "20123456", "20123456"),
                  json=vips_mock.status_applied_not_paid("IRP", date_served),
                  status=200)

    responses.add(responses.GET,
                  '{}/{}/payment/status/{}'.format(
                      Config.VIPS_API_ROOT_URL, "bb71037c-f87b-0444-e054-00144ff95452", "20123456"),
                  json=vips_mock.payment_get(payment_date),
                  status=200)


    monkeypatch.setattr(routes, "RabbitMQ", mock_rabbitmq)

    response = client.post('/schedule',
                           headers=get_basic_authentication_header(monkeypatch),
                           data=get_evidence_form_data())
    json_data = response.json
    logging.warning(json_data)
    assert response.status_code == 200
    assert json_data['data']['is_success'] is False
    assert json_data['data']['error'] == "You are outside the 24-hour time allowed to schedule the review. " \
                                         "Please call Appeals at 250-356-6573."
def test_an_applicant_cannot_submit_evidence_if_they_have_not_paid(client, monkeypatch):

    responses.add(responses.GET,
                  '{}/{}/status/{}'.format(Config.VIPS_API_ROOT_URL, "20123456", "20123456"),
                  json=vips_mock.status_applied_not_paid("IRP"),
                  status=200)

    monkeypatch.setattr(routes, "RabbitMQ", mock_rabbitmq)

    response = client.post('/evidence',
                           headers=get_basic_authentication_header(monkeypatch),
                           data=get_evidence_form_data())
    json_data = response.json
    assert response.status_code == 200
    assert "You must pay before you can submit evidence." in json_data['data']['error']
    assert json_data['data']['is_valid'] is False
def test_an_applicants_last_name_must_match_vips_to_schedule(client, monkeypatch):
    iso_format = "%Y-%m-%d"
    date_served = (datetime.datetime.now() - datetime.timedelta(days=5)).strftime(iso_format)

    responses.add(responses.GET,
                  '{}/{}/status/{}'.format(Config.VIPS_API_ROOT_URL, "20123456", "20123456"),
                  json=vips_mock.status_applied_not_paid("IRP", date_served),
                  status=200)

    monkeypatch.setattr(routes, "RabbitMQ", mock_rabbitmq)

    response = client.post('/schedule',
                           headers=get_basic_authentication_header(monkeypatch),
                           data=get_evidence_form_data(last_name="Wrong"))
    json_data = response.json
    logging.warning(json_data)
    assert response.status_code == 200
    assert json_data['data']['is_success'] is False
    assert json_data['data']['error'] == "The last name doesn't match a driving prohibition in the system."
Beispiel #4
0
def test_an_irp_or_adp_applicant_that_has_previously_applied_gets_appropriate_email(
        prohib, monkeypatch):
    date_served = datetime.datetime.now().strftime("%Y-%m-%d")
    responses.add(responses.GET,
                  '{}/{}/status/{}'.format(Config.VIPS_API_ROOT_URL,
                                           "21999344", "21999344"),
                  json=vips_mock.status_applied_not_paid(prohib, date_served),
                  status=200,
                  match_querystring=True)

    responses.add(responses.POST,
                  '{}/realms/{}/protocol/openid-connect/token'.format(
                      Config.COMM_SERV_AUTH_URL, Config.COMM_SERV_REALM),
                  json={"access_token": "token"},
                  status=200)

    responses.add(responses.POST,
                  '{}/api/v1/email'.format(Config.COMM_SERV_API_ROOT_URL),
                  json={"response": "ignored"},
                  status=200)

    message_dict = get_sample_application_submission(prohib)

    results = helper.middle_logic(helper.get_listeners(
        business.process_incoming_form(), message_dict['event_type']),
                                  message=message_dict,
                                  config=Config,
                                  writer=None)

    email_payload = json.loads(responses.calls[2].request.body.decode())
    assert "*****@*****.**" in email_payload['to']
    assert "Already Applied – Driving Prohibition 21-999344 Review" == email_payload[
        'subject']
    assert "An application to review prohibition 21999344 has already been submitted." in email_payload[
        'body']
    assert "You must call to make changes to your application." in email_payload[
        'body']