Spaces:
Running
Running
GitHub Actions commited on
Commit ·
5b5cb48
1
Parent(s): 5026675
Sync from GitHub · 2026-09-24 17:31 UTC
Browse files- pytest.ini +2 -0
- requirements-dev.txt +3 -0
- tests/conftest.py +10 -0
- tests/test_bff_stage_guidance.py +41 -0
pytest.ini
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
testpaths = tests
|
requirements-dev.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dev/test-only dependencies. Install with: pip install -r requirements-dev.txt
|
| 2 |
+
-r requirements.txt
|
| 3 |
+
pytest>=8.0.0
|
tests/conftest.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Runs before any test module is imported (pytest loads conftest.py first).
|
| 2 |
+
#
|
| 3 |
+
# routes/bff.py imports utils/groq_client.py at module level, which raises
|
| 4 |
+
# RuntimeError at import time if no GROQ_API_KEY* env var is set (see its own
|
| 5 |
+
# docstring). Tests here only exercise pure functions (_stage_guidance,
|
| 6 |
+
# BUSINESS_STAGES) that never make a real Groq call, so a fake key is enough
|
| 7 |
+
# to get past import — never make a real network call using this value.
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
os.environ.setdefault("GROQ_API_KEY", "test-key-not-a-real-credential")
|
tests/test_bff_stage_guidance.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Unit tests for the pure stage → prompt-guidance logic in routes/bff.py.
|
| 3 |
+
|
| 4 |
+
Scope note (docs/qa/test-strategy.md): this deliberately stays at the level of
|
| 5 |
+
"does the right guidance string get picked for the right stage", not "is the
|
| 6 |
+
Groq call correct" — real Groq calls are explicitly out of scope for
|
| 7 |
+
automation (cost, non-determinism, rate limits; see ADR-0009).
|
| 8 |
+
"""
|
| 9 |
+
from routes.bff import _stage_guidance, BUSINESS_STAGES, PRE_LAUNCH_STAGES
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def test_unknown_or_empty_stage_returns_no_guidance():
|
| 13 |
+
assert _stage_guidance("") == ""
|
| 14 |
+
assert _stage_guidance("not-a-real-stage-id") == ""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def test_pre_launch_stages_tell_the_model_not_to_assume_customers():
|
| 18 |
+
for stage in PRE_LAUNCH_STAGES:
|
| 19 |
+
guidance = _stage_guidance(stage)
|
| 20 |
+
assert "has NOT launched" in guidance
|
| 21 |
+
assert BUSINESS_STAGES[stage] in guidance
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_restarting_gets_its_own_guidance_not_the_pre_launch_wording():
|
| 25 |
+
guidance = _stage_guidance("restarting")
|
| 26 |
+
assert "starting again or pivoting" in guidance.lower() or "changing direction" in guidance.lower()
|
| 27 |
+
assert "has NOT launched" not in guidance
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_operating_stages_ask_about_real_experience():
|
| 31 |
+
operating_stages = set(BUSINESS_STAGES) - PRE_LAUNCH_STAGES - {"restarting"}
|
| 32 |
+
assert operating_stages, "expected at least one operating stage to exist"
|
| 33 |
+
for stage in operating_stages:
|
| 34 |
+
guidance = _stage_guidance(stage)
|
| 35 |
+
assert "already operating" in guidance
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def test_pre_launch_stages_are_a_subset_of_known_stages():
|
| 39 |
+
# Guards against PRE_LAUNCH_STAGES and BUSINESS_STAGES drifting apart if a
|
| 40 |
+
# stage is ever renamed on one side and not the other.
|
| 41 |
+
assert PRE_LAUNCH_STAGES <= set(BUSINESS_STAGES.keys())
|