meal-order-manager/tests/test_app.py
Adam Moussa 3e9a1c60bf
feat(api): serve meals on ECS Fargate instead of Lambda
Keep the Flask app always-on with in-process jobs so CloudFront no longer fronts a cold-start API Gateway.
2026-09-21 14:37:48 -04:00

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"]