Files
Jyotisha/tests/test_kalanala_chakra.py
T
ClaudeandClaude Opus 5.5 ac9be6f88c feat(techniques): port the astrologer upstream skill's missing techniques
Port from yinduzhanxing 5fb8379c (MIT): Naisargika, Kaala, Karaka, Tara,
Lagnamsaka, Yogardha, Mandooka, Paryaaya and Padanadhamsa dashas;
Sarvatobhadra, Kota and Kalanala chakras; Nakshatra Latta; Pachakadi;
Raman Amsayu and Pindayu. Producers and their upstream tests are copied;
scripts/upstream_technique_layers.py feeds them our natal and transit
positions and attaches chart.consultation_native_layers.upstream_techniques.

- dasha_registry: kaala and padanadhamsa keys (35 -> 37); the nine ported
  dashas are served by compute_dasha or fail closed with upstream's reason.
- technique_registry.json: 16 partial entries; README badges follow.
- Evidence lookup section `upstream_techniques` in the consultation tool.
- Boundaries: Kalanala carries no PyJHora (AGPL) grid coordinates;
  Padanadhamsa/Lagnamsaka run on our Narayana engine (no Rath Table 12,
  PVR co-lord variants or second cycle). PyJHora observers and the Amsayu
  worked-example scaffold live in scripts/research (root .py budget).
- PyJHora black-box cross-checks: Naisargika (lords/years) and Kaala
  (seed segment and fraction within 5e-4) on a public chart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-07 14:44:37 +08:00

40 lines
2.4 KiB
Python

import pytest
from scripts.kalanala_chakra import build_kalanala_report, read_pyjhora_kalanala_positions
STARS={p:1 for p in ('Sun','Moon','Mars','Mercury','Jupiter','Venus','Saturn','Rahu','Ketu')}
@pytest.mark.parametrize('kind',('chandra','surya'))
def test_layout_keeps_kind_base_and_planet_slots(kind):
r=build_kalanala_report(stars=STARS,base_star=18,ayanamsa='lahiri',kind=kind); e=r['evidence_appendix'][0]
assert e['kind']==kind and e['base_star']==18 and len(e['rows'])==9
assert all(x['target_star_index']==1 and x['layout_slot']==12 for x in e['rows'])
assert r['customer_export_admitted'] is False
@pytest.mark.parametrize('bad',('',0,29,True))
def test_invalid_base_rejected(bad):
with pytest.raises(ValueError): build_kalanala_report(stars=STARS,base_star=bad,ayanamsa='lahiri')
def test_invalid_star_and_kind_rejected():
with pytest.raises(ValueError): build_kalanala_report(stars={**STARS,'Sun':28},base_star=18,ayanamsa='lahiri')
with pytest.raises(ValueError): build_kalanala_report(stars=STARS,base_star=18,ayanamsa='lahiri',kind='x')
@pytest.mark.parametrize('kind,first,rotated', [('chandra',(5,1),(5,6)), ('surya',(8,15),(5,1))])
def test_base_rotation_changes_planet_coordinates(kind,first,rotated):
# Grid coordinates come from the installed PyJHora (black-box read); the
# repo does not carry the AGPL layout table itself.
pytest.importorskip('jhora')
positions = read_pyjhora_kalanala_positions(kind)
def row(base):
return build_kalanala_report(stars=STARS,base_star=base,ayanamsa='lahiri',kind=kind,positions=positions)['evidence_appendix'][0]['rows'][0]
assert row(1)['grid'] == first
assert row(18)['grid'] == rotated
assert row(1)['source_star_index'] == row(18)['source_star_index'] == 1
@pytest.mark.parametrize('star,target', [(21,21),(22,23),(27,28)])
def test_abhijit_gap_preserves_absolute_star_identity(star,target):
row=build_kalanala_report(stars={**STARS,'Sun':star},base_star=1,ayanamsa='lahiri')['evidence_appendix'][0]['rows'][0]
assert row['target_star_index'] == target
assert row['layout_slot'] == target
def test_without_external_layout_grid_stays_empty_and_partial():
e=build_kalanala_report(stars=STARS,base_star=18,ayanamsa='lahiri')['evidence_appendix'][0]
assert e['status']=='partial' and e['grid_status']=='not_carried_agpl_boundary'
assert all(r['grid'] is None for r in e['rows'])