Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
56 lines
2.8 KiB
Python
56 lines
2.8 KiB
Python
"""#185 / BUG-1828 acceptance additions (Claude, 2026-11-09).
|
|
|
|
The brief's acceptance items 3 and 4 were not in Grok's test file: computed values must not change when the
|
|
modes are omitted versus sent explicitly as the product defaults, and the consultation workflow must report
|
|
the effective calculation profile. Synthetic neutral chart only.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
for path in (str(ROOT), str(ROOT / 'scripts')):
|
|
if path not in sys.path:
|
|
sys.path.insert(0, path)
|
|
|
|
import jyotish_api_server as server # noqa: E402
|
|
from tests.neutral_subject import ( # noqa: E402
|
|
NEUTRAL_DAY, NEUTRAL_HOUR, NEUTRAL_LAT, NEUTRAL_LON, NEUTRAL_MINUTE, NEUTRAL_MONTH, NEUTRAL_TZ, NEUTRAL_YEAR,
|
|
)
|
|
|
|
BIRTH = {
|
|
'year': NEUTRAL_YEAR, 'month': NEUTRAL_MONTH, 'day': NEUTRAL_DAY, 'hour': NEUTRAL_HOUR, 'minute': NEUTRAL_MINUTE,
|
|
'lat': NEUTRAL_LAT, 'lon': NEUTRAL_LON, 'tz': NEUTRAL_TZ, 'ayanamsa': 'lahiri',
|
|
'today': '2026-11-09', 'transit_date': '2026-11-09', 'skip_vedastro_main_entry_overview': True,
|
|
}
|
|
|
|
|
|
def test_explicit_default_modes_compute_the_same_chart_as_omitted_modes(monkeypatch, tmp_path) -> None:
|
|
# A fresh cache directory per call, so the second call cannot be served from the first call's cache entry.
|
|
service = server.JyotishComputeService()
|
|
results = []
|
|
for index, body in enumerate((dict(BIRTH), {**BIRTH, 'node_mode': 'mean', 'position_mode': 'apparent'})):
|
|
monkeypatch.setattr(server, '_api_chart_cache_dir', lambda index=index: tmp_path / f'cache-{index}')
|
|
result = service._compute_chart_sync(body)
|
|
assert (result.get('runtime_cache') or {}).get('cache_hit') is not True
|
|
results.append(result)
|
|
omitted, explicit = results
|
|
assert omitted['result_hash'] == explicit['result_hash']
|
|
assert omitted['planets'] == explicit['planets']
|
|
assert omitted['ascendant'] == explicit['ascendant']
|
|
assert omitted['runtime_cache']['cache_key'] == explicit['runtime_cache']['cache_key']
|
|
|
|
|
|
def test_consultation_workflow_reports_the_effective_calculation_profile() -> None:
|
|
handler = server.JyotishComputeService()
|
|
base = {**BIRTH, 'question': '事业整体如何?', 'theme': 'career', 'plan_only': True}
|
|
defaulted = server.execute_consultation_workflow(handler, body=dict(base))
|
|
assert defaulted['calculation_profile'] == {
|
|
'node_mode': 'mean', 'position_mode': 'apparent', 'profile_source': 'product_default_explicit', 'ayanamsa': 'lahiri',
|
|
}
|
|
supplied = server.execute_consultation_workflow(handler, body={**base, 'node_mode': 'true', 'position_mode': 'apparent'})
|
|
assert supplied['calculation_profile']['node_mode'] == 'true'
|
|
assert supplied['calculation_profile']['profile_source'] == 'caller_supplied'
|