mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 17:03:13 +00:00
Keep the Flask app always-on with in-process jobs so CloudFront no longer fronts a cold-start API Gateway.
31 lines
987 B
Python
31 lines
987 B
Python
"""Flask app health and CORS preflight."""
|
|
|
|
import os
|
|
|
|
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
|
|
os.environ.setdefault("TABLE_NAME", "test-orders-table")
|
|
|
|
from server.app import create_app
|
|
|
|
|
|
def test_health_returns_stage_and_sha(monkeypatch):
|
|
monkeypatch.setenv("STAGE", "local")
|
|
monkeypatch.setenv("GIT_SHA", "abc123")
|
|
client = create_app().test_client()
|
|
response = client.get("/api/health")
|
|
assert response.status_code == 200
|
|
assert response.get_json() == {"stage": "local", "sha": "abc123"}
|
|
|
|
|
|
def test_options_preflight_from_portal_origin():
|
|
client = create_app().test_client()
|
|
response = client.options(
|
|
"/api/submit-order",
|
|
headers={"Origin": "https://internal.seahaven.com"},
|
|
)
|
|
assert response.status_code == 204
|
|
assert (
|
|
response.headers["Access-Control-Allow-Origin"]
|
|
== "https://internal.seahaven.com"
|
|
)
|
|
assert "Authorization" in response.headers["Access-Control-Allow-Headers"]
|