From f371c393a2fb613758c29760f2761ec533b751cb Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 23 Jun 2016 16:44:57 +0100 Subject: [PATCH] rename renew_api_key to create_api_key --- app/service/rest.py | 3 +-- tests/app/service/test_api_key_endpoints.py | 8 ++++---- tests/app/service/test_url_for.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/service/rest.py b/app/service/rest.py index d4b4519b7..e94107260 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -95,9 +95,8 @@ def update_service(service_id): return jsonify(data=service_schema.dump(fetched_service).data), 200 -# is this used. @service.route('//api-key', methods=['POST']) -def renew_api_key(service_id=None): +def create_api_key(service_id=None): fetched_service = dao_fetch_service_by_id(service_id=service_id) valid_api_key = api_key_schema.load(request.get_json()).data valid_api_key.service = fetched_service diff --git a/tests/app/service/test_api_key_endpoints.py b/tests/app/service/test_api_key_endpoints.py index c673dfc30..045a37a30 100644 --- a/tests/app/service/test_api_key_endpoints.py +++ b/tests/app/service/test_api_key_endpoints.py @@ -17,7 +17,7 @@ def test_api_key_should_create_new_api_key_for_service(notify_api, notify_db, with notify_api.test_client() as client: data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)} auth_header = create_authorization_header() - response = client.post(url_for('service.renew_api_key', service_id=sample_service.id), + response = client.post(url_for('service.create_api_key', service_id=sample_service.id), data=json.dumps(data), headers=[('Content-Type', 'application/json'), auth_header]) assert response.status_code == 201 @@ -34,7 +34,7 @@ def test_api_key_should_return_error_when_service_does_not_exist(notify_api, not import uuid missing_service_id = uuid.uuid4() auth_header = create_authorization_header() - response = client.post(url_for('service.renew_api_key', service_id=missing_service_id), + response = client.post(url_for('service.create_api_key', service_id=missing_service_id), headers=[('Content-Type', 'application/json'), auth_header]) assert response.status_code == 404 @@ -62,14 +62,14 @@ def test_api_key_should_create_multiple_new_api_key_for_service(notify_api, noti assert ApiKey.query.count() == 0 data = {'name': 'some secret name', 'created_by': str(sample_service.created_by.id)} auth_header = create_authorization_header() - response = client.post(url_for('service.renew_api_key', service_id=sample_service.id), + response = client.post(url_for('service.create_api_key', service_id=sample_service.id), data=json.dumps(data), headers=[('Content-Type', 'application/json'), auth_header]) assert response.status_code == 201 assert ApiKey.query.count() == 1 data = {'name': 'another secret name', 'created_by': str(sample_service.created_by.id)} auth_header = create_authorization_header() - response2 = client.post(url_for('service.renew_api_key', service_id=sample_service.id), + response2 = client.post(url_for('service.create_api_key', service_id=sample_service.id), data=json.dumps(data), headers=[('Content-Type', 'application/json'), auth_header]) assert response2.status_code == 201 diff --git a/tests/app/service/test_url_for.py b/tests/app/service/test_url_for.py index 286b949d1..c0c44cd1d 100644 --- a/tests/app/service/test_url_for.py +++ b/tests/app/service/test_url_for.py @@ -34,7 +34,7 @@ def test_url_for_update_service(notify_api): assert str(url) == '/service/{}'.format(service_id) -def test_url_for_renew_api_key(notify_api): +def test_url_for_create_api_key(notify_api): with notify_api.test_request_context(): - url = url_for('service.renew_api_key', service_id=service_id) + url = url_for('service.create_api_key', service_id=service_id) assert str(url) == '/service/{}/api-key'.format(service_id)