mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
Added a test to ensure that all blueprints have a registered before_request method.
Added a test for the status endpoint.
This commit is contained in:
13
tests/app/status/test_status.py
Normal file
13
tests/app/status/test_status.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from flask import json
|
||||
|
||||
|
||||
def test_get_status_all_ok(client):
|
||||
path = '/_status'
|
||||
response = client.get(path)
|
||||
assert response.status_code == 200
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
assert resp_json['status'] == 'ok'
|
||||
assert resp_json['db_version']
|
||||
assert resp_json['travis_commit']
|
||||
assert resp_json['travis_build_number']
|
||||
assert resp_json['build_time']
|
||||
12
tests/app/test_route_authentication.py
Normal file
12
tests/app/test_route_authentication.py
Normal file
@@ -0,0 +1,12 @@
|
||||
def test_all_routes_have_authentication(client):
|
||||
# This tests that each blueprint registered on the application has a before_request function registered.
|
||||
# The None row is removed from the comparison as that is not blueprint specific but app specific.
|
||||
before_req_funcs = set(x for x in client.application.before_request_funcs if x is not None)
|
||||
|
||||
blueprint_names = set(client.application.blueprints.keys())
|
||||
assert blueprint_names == before_req_funcs
|
||||
|
||||
# The static route is always available by default for a Flask app to serve anything in the static folder.
|
||||
routes_blueprint_names = set(
|
||||
[x.split('.')[0] for x in client.application.view_functions.keys() if x.split('.')[0] != 'static'])
|
||||
assert sorted(blueprint_names) == sorted(routes_blueprint_names)
|
||||
Reference in New Issue
Block a user