def edit_endpoint(id, label=None, url=None, description=None, tags=None): code = CRUD.editEndpoint(id, label=label, url=url, description=description, tags=tags, commit=True) if code == 0: return { 'status': 'error', 'message': 'Endpoint #%d was not found' % id, 'id': id } elif code == -1: return { 'status': 'error', 'message': 'Oooops! Something went wrong while editing Endpoint #%d' % id, 'id': id } elif code > 0: return { 'status': 'ok', 'message': 'Endpoint #%d was successfully edited' % id, 'id': id }
def test_edit_endpoint_by_id(mock_crud, context_endpoint): print('\n=> Testing editing endpoint by id') endpoint_id = context_endpoint.get('endpoint_id') label = generate_random_string() url = generate_random_string() description = ' '.join([generate_random_string() for _ in range(5)]) tags = ' '.join([generate_random_string() for _ in range(5)]) code = CRUD.editEndpoint( endpoint_id, label=label, url=url, description=description, tags=tags ) assert code>0 endpoint = CRUD.getEndpoint(endpoint_id) assert endpoint.label == label assert endpoint.url == url assert endpoint.description == description assert set(tags.split()) == set([t.text for t in endpoint.tags])