mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Update service_id to a UUID from an integer.
This commit must go along side a commit on the notifications-api app. There will be a breif outage until both app are deployed.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import uuid
|
||||
from datetime import date
|
||||
from flask import url_for
|
||||
|
||||
@@ -10,7 +11,7 @@ def test_should_show_api_keys_and_documentation_page(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.documentation', service_id=123))
|
||||
response = client.get(url_for('main.documentation', service_id=uuid.uuid4()))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -24,12 +25,13 @@ def test_should_show_empty_api_keys_page(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.api_keys', service_id=123))
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for('main.api_keys', service_id=service_id))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'You haven’t created any API keys yet' in response.get_data(as_text=True)
|
||||
assert 'Create a new API key' in response.get_data(as_text=True)
|
||||
mock_get_no_api_keys.assert_called_once_with(service_id=123)
|
||||
mock_get_no_api_keys.assert_called_once_with(service_id=service_id)
|
||||
|
||||
|
||||
def test_should_show_api_keys_page(app_,
|
||||
@@ -41,13 +43,14 @@ def test_should_show_api_keys_page(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.api_keys', service_id=123))
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for('main.api_keys', service_id=service_id))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'some key name' in response.get_data(as_text=True)
|
||||
assert 'another key name' in response.get_data(as_text=True)
|
||||
assert 'Revoked Thursday 01 January 1970 at 00:00' in response.get_data(as_text=True)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=123)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=service_id)
|
||||
|
||||
|
||||
def test_should_show_name_api_key_page(app_,
|
||||
@@ -59,7 +62,8 @@ def test_should_show_name_api_key_page(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.create_api_key', service_id=123))
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for('main.create_api_key', service_id=service_id))
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -74,12 +78,13 @@ def test_should_render_show_api_key(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.post(url_for('main.create_api_key', service_id=123),
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.post(url_for('main.create_api_key', service_id=service_id),
|
||||
data={'key_name': 'some default key name'})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'some default key name' in response.get_data(as_text=True)
|
||||
mock_create_api_key.assert_called_once_with(service_id=123, key_name='some default key name')
|
||||
mock_create_api_key.assert_called_once_with(service_id=service_id, key_name='some default key name')
|
||||
|
||||
|
||||
def test_should_show_confirm_revoke_api_key(app_,
|
||||
@@ -91,11 +96,12 @@ def test_should_show_confirm_revoke_api_key(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.revoke_api_key', service_id=123, key_id=321))
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for('main.revoke_api_key', service_id=service_id, key_id=321))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'some key name' in response.get_data(as_text=True)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=123, key_id=321)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=service_id, key_id=321)
|
||||
|
||||
|
||||
def test_should_redirect_after_revoking_api_key(app_,
|
||||
@@ -108,9 +114,10 @@ def test_should_redirect_after_revoking_api_key(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.post(url_for('main.revoke_api_key', service_id=123, key_id=321))
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.post(url_for('main.revoke_api_key', service_id=service_id, key_id=321))
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('.api_keys', service_id=123, _external=True)
|
||||
mock_revoke_api_key.assert_called_once_with(service_id=123, key_id=321)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=123, key_id=321)
|
||||
assert response.location == url_for('.api_keys', service_id=service_id, _external=True)
|
||||
mock_revoke_api_key.assert_called_once_with(service_id=service_id, key_id=321)
|
||||
mock_get_api_keys.assert_called_once_with(service_id=service_id, key_id=321)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from flask import url_for
|
||||
|
||||
|
||||
@@ -11,7 +13,7 @@ def test_should_return_list_of_all_templates(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
service_id = 123
|
||||
service_id = str(uuid.uuid4())
|
||||
response = client.get(url_for(
|
||||
'.manage_service_templates', service_id=service_id))
|
||||
|
||||
@@ -28,7 +30,7 @@ def test_should_show_page_for_one_templates(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
service_id = 123
|
||||
service_id = str(uuid.uuid4())
|
||||
template_id = 456
|
||||
response = client.get(url_for(
|
||||
'.edit_service_template',
|
||||
@@ -52,7 +54,7 @@ def test_should_redirect_when_saving_a_template(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
service_id = 123
|
||||
service_id = str(uuid.uuid4())
|
||||
template_id = 456
|
||||
name = "new name"
|
||||
type_ = "sms"
|
||||
@@ -85,7 +87,7 @@ def test_should_show_delete_template_page(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
service_id = 123
|
||||
service_id = str(uuid.uuid4())
|
||||
template_id = 456
|
||||
response = client.get(url_for(
|
||||
'.delete_service_template',
|
||||
@@ -108,7 +110,7 @@ def test_should_redirect_when_deleting_a_template(app_,
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
service_id = 123
|
||||
service_id = str(uuid.uuid4())
|
||||
template_id = 456
|
||||
name = "new name"
|
||||
type_ = "sms"
|
||||
|
||||
Reference in New Issue
Block a user