Ejemplo n.º 1
0
def test_update_reply_to_email_address_raises_exception_if_single_reply_to_and_setting_default_to_false(sample_service):
    first_reply_to = create_reply_to_email(service=sample_service, email_address="*****@*****.**")
    with pytest.raises(expected_exception=InvalidRequest):
        update_reply_to_email_address(service_id=sample_service.id,
                                      reply_to_id=first_reply_to.id,
                                      email_address='*****@*****.**',
                                      is_default=False)
Ejemplo n.º 2
0
def test_update_reply_to_email_address(sample_service):
    first_reply_to = create_reply_to_email(service=sample_service, email_address="*****@*****.**")
    update_reply_to_email_address(service_id=sample_service.id, reply_to_id=first_reply_to.id,
                                  email_address='*****@*****.**',
                                  is_default=True)
    updated_reply_to = ServiceEmailReplyTo.query.get(first_reply_to.id)

    assert updated_reply_to.email_address == '*****@*****.**'
    assert updated_reply_to.updated_at
    assert updated_reply_to.is_default
Ejemplo n.º 3
0
def update_service_reply_to_email_address(service_id, reply_to_email_id):
    # validate the service exists, throws ResultNotFound exception.
    dao_fetch_service_by_id(service_id)
    form = validate(request.get_json(), add_service_email_reply_to_request)
    new_reply_to = update_reply_to_email_address(service_id=service_id,
                                                 reply_to_id=reply_to_email_id,
                                                 email_address=form['email_address'],
                                                 is_default=form.get('is_default', True))
    return jsonify(data=new_reply_to.serialize()), 200
Ejemplo n.º 4
0
def test_update_reply_to_email_address_set_updated_to_default(sample_service):
    create_reply_to_email(service=sample_service, email_address="*****@*****.**")
    second_reply_to = create_reply_to_email(service=sample_service,
                                            email_address="*****@*****.**",
                                            is_default=False)

    update_reply_to_email_address(service_id=sample_service.id,
                                  reply_to_id=second_reply_to.id,
                                  email_address='*****@*****.**',
                                  is_default=True)

    results = ServiceEmailReplyTo.query.all()
    assert len(results) == 2
    for x in results:
        if x.email_address == '*****@*****.**':
            assert x.is_default
        elif x.email_address == '*****@*****.**':
            assert not x.is_default
        else:
            assert False