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
def test_edit_field_by_id(mock_crud, context_field): print('\n=> Testing editing field by id') field_id = context_field.get('field_id') label = generate_random_string() type_field = generate_random_string() description = ' '.join([generate_random_string() for _ in range(5)]) default = generate_random_string() required = random.choice([True, False]) code = CRUD.editField( field_id, label=label, type_field=type_field, description=description, default=default, required=required, commit=False ) assert code>0 field = CRUD.getField(field_id) assert field.label == label assert field.type == type_field assert field.description == description assert field.default == default assert field.required == required
def get_field(id): field = CRUD.getField(id) if not field: return {} j = field_schema.dump(field) return j