mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
Move view function into own file, add test
This commit is contained in:
@@ -5,5 +5,5 @@ main = Blueprint('main', __name__)
|
||||
from app.main.views import (
|
||||
index, sign_in, sign_out, register, two_factor, verify, sms, add_service,
|
||||
code_not_received, jobs, dashboard, templates, service_settings, forgot_password,
|
||||
new_password, styleguide, user_profile, choose_service
|
||||
new_password, styleguide, user_profile, choose_service, api_keys
|
||||
)
|
||||
|
||||
9
app/main/views/api_keys.py
Normal file
9
app/main/views/api_keys.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from flask import render_template
|
||||
from flask_login import login_required
|
||||
from app.main import main
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/api-keys")
|
||||
@login_required
|
||||
def api_keys(service_id):
|
||||
return render_template('views/api-keys.html', service_id=service_id)
|
||||
@@ -36,9 +36,3 @@ def checkemail(service_id):
|
||||
@login_required
|
||||
def manageusers(service_id):
|
||||
return render_template('views/manage-users.html', service_id=service_id)
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/api-keys")
|
||||
@login_required
|
||||
def apikeys(service_id):
|
||||
return render_template('views/api-keys.html', service_id=service_id)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<li><a href="{{ url_for('.manage_templates', service_id=123) }}">Templates</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="{{ url_for('.apikeys', service_id=123) }}">API keys and documentation</a></li>
|
||||
<li><a href="{{ url_for('.api_keys', service_id=123) }}">API keys and documentation</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="{{ url_for('.manageusers', service_id=123) }}">Manage users</a></li>
|
||||
|
||||
14
tests/app/main/views/test_api_keys.py
Normal file
14
tests/app/main/views/test_api_keys.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from tests.app.main import create_test_user
|
||||
from flask import url_for
|
||||
|
||||
|
||||
def test_should_show_api_keys_and_documentation_page(notifications_admin,
|
||||
notifications_admin_db,
|
||||
notify_db_session):
|
||||
with notifications_admin.test_request_context():
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get(url_for('.api_keys', service_id=123))
|
||||
|
||||
assert response.status_code == 200
|
||||
Reference in New Issue
Block a user