Esempio n. 1
0
def test_update_service_data_retention_does_not_update_if_row_does_not_exist(
        sample_service):
    updated_count = update_service_data_retention(
        service_data_retention_id=uuid.uuid4(),
        service_id=sample_service.id,
        days_of_retention=5)
    assert updated_count == 0
    assert len(ServiceDataRetention.query.all()) == 0
Esempio n. 2
0
def test_update_service_data_retention_does_not_update_row_if_data_retention_is_for_different_service(
        sample_service):
    data_retention = insert_service_data_retention(
        service_id=sample_service.id,
        notification_type='email',
        days_of_retention=3)
    updated_count = update_service_data_retention(
        service_data_retention_id=data_retention.id,
        service_id=uuid.uuid4(),
        days_of_retention=5)
    assert updated_count == 0
Esempio n. 3
0
def modify_service_data_retention(service_id, data_retention_id):
    form = validate(request.get_json(), update_service_data_retention_request)

    update_count = update_service_data_retention(
        service_data_retention_id=data_retention_id,
        service_id=service_id,
        days_of_retention=form.get("days_of_retention"))
    if update_count == 0:
        raise InvalidRequest(
            message=
            "The service data retention for id: {} was not found for service: {}"
            .format(data_retention_id, service_id),
            status_code=404)

    return '', 204
Esempio n. 4
0
def test_update_service_data_retention(sample_service):
    data_retention = insert_service_data_retention(
        service_id=sample_service.id,
        notification_type='sms',
        days_of_retention=3)
    updated_count = update_service_data_retention(
        service_data_retention_id=data_retention.id,
        service_id=sample_service.id,
        days_of_retention=5)
    assert updated_count == 1
    results = ServiceDataRetention.query.all()
    assert len(results) == 1
    assert results[0].id == data_retention.id
    assert results[0].service_id == sample_service.id
    assert results[0].notification_type == 'sms'
    assert results[0].days_of_retention == 5
    assert results[0].created_at.date() == datetime.utcnow().date()
    assert results[0].updated_at.date() == datetime.utcnow().date()