mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 18:13:13 +00:00
Keep the Flask app always-on with in-process jobs so CloudFront no longer fronts a cold-start API Gateway.
27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
"""Pytest configuration — add shared layer source to sys.path so handler imports resolve."""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Several Lambda handlers construct boto3.client(...) at module load. On a CI
|
|
# runner with no AWS config this raises NoRegionError during test collection
|
|
# (a real region is read from ~/.aws/config locally, masking it). Set a default
|
|
# region before any import. Client construction is offline; real calls are mocked.
|
|
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
|
|
os.environ.setdefault("AWS_REGION", "us-east-1")
|
|
|
|
# Add the repo root so `import functions.<name>.handler` resolves under a bare
|
|
# `pytest` invocation. `python -m pytest` injects the CWD automatically, but CI
|
|
# runs `pytest` directly, which does not — hence tests passed locally yet failed
|
|
# to collect in CI.
|
|
_repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
|
sys.path.insert(0, _repo_root)
|
|
|
|
# Add src/ so `from server.http_api import ...` and `from server.jobs import ...` work.
|
|
_src_dir = os.path.join(os.path.dirname(__file__), os.pardir, "src")
|
|
sys.path.insert(0, os.path.abspath(_src_dir))
|
|
|
|
# Add the shared layer source directory so `from shared.db import ...` works
|
|
# without requiring a real Lambda layer or .aws-sam build.
|
|
_shared_layer_dir = os.path.join(_src_dir, "shared")
|
|
sys.path.insert(0, os.path.abspath(_shared_layer_dir))
|