コード例 #1
0
def test_cascade_delete_api_by_id(mock_crud, context_field):
    print('\n=> Testing cascade deleting api by id')
    api_id = context_field.get('api_id')
    endpoint_id = context_field.get('endpoint_id')
    field_id = context_field.get('field_id')

    code = CRUD.deleteApi(api_id)
    assert code>0
    existing_endpoint_id = CRUD.getEndpoint(endpoint_id)
    assert existing_endpoint_id is None
    existing_field = CRUD.getField(field_id)
    assert existing_field is None
コード例 #2
0
 def delete_api(id):
     code = CRUD.deleteApi(id, commit=True)
     if code == 0:
         return {
             'status': 'error',
             'message':
             'API #%d was not found. Maybe it was alredy deleted' % id,
             'id': id
         }
     elif code == -1:
         return {
             'status': 'error',
             'message':
             'Oooops! Something went wrong while deleting API #%d' % id,
             'id': id
         }
     elif code > 0:
         return {
             'status': 'ok',
             'message': "API #%d was successfully deleted" % id,
             'id': id
         }