Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preload env variable for /_status/check and update dependencies #49

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion canonicalwebteam/flask_base/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
prepare_redirects,
)

STATUS_CHECK = os.getenv("TALISKER_REVISION_ID", "OK")


def set_security_headers(response):
add_xframe_options_header = True
Expand Down Expand Up @@ -208,7 +210,7 @@ def internal_error(error):
# Default routes
@self.route("/_status/check")
def status_check():
return os.getenv("TALISKER_REVISION_ID", "OK")
return STATUS_CHECK

favicon_path = os.path.join(self.root_path, "../static", "favicon.ico")
if os.path.isfile(favicon_path):
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="canonicalwebteam.flask-base",
version="0.9.0",
version="0.9.1",
description=(
"Flask extension that applies common configurations"
"to all of webteam's flask apps."
Expand All @@ -22,9 +22,9 @@
install_requires=[
"canonicalwebteam.yaml-responses[flask] (>=1,<2)",
"flask (>=1,<2)",
"gevent==20.6.2",
"greenlet==0.4.16",
"talisker[gunicorn,gevent,flask,prometheus,raven] (>=0.18)",
"gevent==21.8.0",
"greenlet==1.1.2",
"talisker[gunicorn,gevent,flask,prometheus,raven]==0.19.0",
"Werkzeug (>=0.15,<0.16)",
],
dependency_links=[],
Expand Down
3 changes: 1 addition & 2 deletions tests/test_flask_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ def test_cache_override(self):

def test_status_endpoints(self):
with create_test_app().test_client() as client:
os.environ["TALISKER_REVISION_ID"] = "a-build-id"
response = client.get("_status/check")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data.decode(), "a-build-id")
self.assertEqual(response.data.decode(), "OK")
self.assertEqual(response.headers.get("Cache-Control"), "no-store")

def test_redirects_deleted(self):
Expand Down