mirror of
https://github.com/migatu/astrololo.git
synced 2026-07-14 13:34:38 +00:00
f6323cac10
Punktacja siły (LOG-21): - scoring.py: siła fasety z sygnałów obliczalnych (typ fasety, rodzaj aspektu, ciasnota orbu). Konfigurowalne wagi. Hook na przyszłość: kolumny countas*/level* z SIGNIFICATORS KEY (obecnie puste). - aspekty niosą orb+allowed; fasety dostają "score"; ranking faset malejąco. Grupowanie: - opcja group: zwija próbki po opisie (ten sam efekt = jedna grupa z listą sygnifikatorów i licznikiem). Checkbox "grupuj identyczne opisy" w /interpret. Geolokalizacja (bajer): - "Tu i teraz" (widok Horoskop i Interpretacje) uzupełnia lat/lon z przeglądarki (navigator.geolocation; wymaga zgody, https/localhost). Zweryfikowano na realnym main_base.xlsx: ranking sensowny (ciasna opozycja z Saturn 9.59 > szeroka koniunkcja z Moon 6.25 > znak/dom 5.0); grupowanie zwija powtórzone opisy. 41 testów przechodzi. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
94 lines
4.3 KiB
Python
94 lines
4.3 KiB
Python
"""Testy mostu obliczenia → sygnifikatory → wyszukiwanie (bez efemeryd/HTTP)."""
|
|
from app.engine.models import DEFAULT_OBJECTS
|
|
from app.significators import PLANET_ABBR, _ordinal, build_report
|
|
|
|
|
|
class FakeData:
|
|
def __init__(self, rows_by_value: dict) -> None:
|
|
self.rows_by_value = rows_by_value
|
|
|
|
def search(self, key, value, exact, limit, fields=None) -> dict:
|
|
rows = self.rows_by_value.get(value, [])
|
|
return {"provider": "fake", "total": len(rows), "rows": rows}
|
|
|
|
|
|
def test_sign_and_house_facets():
|
|
positions = [{"name": "Sun", "sign": "Taurus", "direction": "D", "house": 11}]
|
|
data = FakeData({"[Su": [
|
|
{"significator": "[Su in [Tau", "actioneffect": "efekt znak"}, # faseta znak
|
|
{"significator": "[Su in 11th H.", "actioneffect": "efekt dom"}, # faseta dom
|
|
{"significator": "[Su in [Vir", "actioneffect": "inny"}, # żadna
|
|
{"significator": "[Su in [Tau", "actioneffect": "nan"}, # szum
|
|
]})
|
|
item = build_report(positions, data)["objects"][0]
|
|
assert item["object"] == "Sun" and item["house"] == 11
|
|
facets = {f["type"]: f for f in item["facets"]}
|
|
assert facets["sign"]["count"] == 1
|
|
assert facets["sign"]["samples"][0]["effect"] == "efekt znak"
|
|
assert facets["sign"]["samples"][0]["expanded"] == "Sun in Taurus" # rozwinięcie skrótu
|
|
assert facets["house"]["count"] == 1
|
|
assert facets["house"]["token"] == "11th H."
|
|
assert facets["house"]["samples"][0]["effect"] == "efekt dom"
|
|
|
|
|
|
def test_no_house_facet_when_house_missing():
|
|
positions = [{"name": "Mars", "sign": "Scorpio", "direction": "Rx"}]
|
|
data = FakeData({"[Ma": [{"significator": "[Ma in [Sco", "actioneffect": "eff"}]})
|
|
types = [f["type"] for f in build_report(positions, data)["objects"][0]["facets"]]
|
|
assert "sign" in types and "house" not in types
|
|
|
|
|
|
def test_dedup_by_significator_and_effect():
|
|
positions = [{"name": "Moon", "sign": "Taurus", "direction": "D", "house": 11}]
|
|
data = FakeData({"[Mo": [
|
|
{"significator": "[Mo in 11th H.", "actioneffect": "efekt"},
|
|
{"significator": "[Mo in 11th H.", "actioneffect": "efekt"}, # duplikat (sig+opis)
|
|
{"significator": "[Mo in 11th H.", "actioneffect": "inny efekt"}, # ten sam sig, inny opis
|
|
]})
|
|
facets = {f["type"]: f for f in build_report(positions, data)["objects"][0]["facets"]}
|
|
assert facets["house"]["count"] == 2 # duplikat odsiany, różny opis zostaje
|
|
|
|
|
|
def test_aspect_facet():
|
|
positions = [
|
|
{"name": "Sun", "sign": "Taurus", "direction": "D", "house": 11},
|
|
{"name": "Moon", "sign": "Taurus", "direction": "D", "house": 11},
|
|
]
|
|
aspects = [{"obj1": "Sun", "obj2": "Moon", "aspect": "conjunction", "orb": 2.0}]
|
|
data = FakeData({"[Su": [{"significator": "[Su [conj [Mo", "actioneffect": "złączeni"}]})
|
|
sun = build_report(positions, data, aspects=aspects)["objects"][0]
|
|
asp = [f for f in sun["facets"] if f["type"] == "aspect"]
|
|
assert asp and asp[0]["count"] == 1 and "Moon" in asp[0]["label"]
|
|
|
|
|
|
def test_grouping_by_effect():
|
|
positions = [{"name": "Mars", "sign": "Scorpio", "direction": "Rx", "house": 5}]
|
|
data = FakeData({"[Ma": [
|
|
{"significator": "[Ma in 5th H.", "actioneffect": "miscarriage"},
|
|
{"significator": "[Sa in 5th H.", "actioneffect": "miscarriage"}, # inny sig, ten sam opis
|
|
{"significator": "[Ma in 5th H.", "actioneffect": "fever"},
|
|
]})
|
|
house = [f for f in build_report(positions, data, group=True)["objects"][0]["facets"]
|
|
if f["type"] == "house"][0]
|
|
groups = {g["effect"]: g for g in house["groups"]}
|
|
assert groups["miscarriage"]["count"] == 2
|
|
assert len(groups["miscarriage"]["significators"]) == 2
|
|
assert "score" in house
|
|
|
|
|
|
def test_facets_carry_score():
|
|
positions = [{"name": "Sun", "sign": "Taurus", "direction": "D", "house": 11}]
|
|
data = FakeData({"[Su": [{"significator": "[Su in [Tau", "actioneffect": "e"}]})
|
|
facets = build_report(positions, data)["objects"][0]["facets"]
|
|
assert all("score" in f for f in facets)
|
|
|
|
|
|
def test_ordinal():
|
|
assert _ordinal(1) == "1st" and _ordinal(2) == "2nd" and _ordinal(3) == "3rd"
|
|
assert _ordinal(4) == "4th" and _ordinal(11) == "11th" and _ordinal(12) == "12th"
|
|
|
|
|
|
def test_planet_abbr_covers_all_default_objects():
|
|
for o in DEFAULT_OBJECTS:
|
|
assert o in PLANET_ABBR
|