fix(rectification): persist the next interview after a choice tap
Closing a discriminator used to leave GET without a card after refresh. Write the next dated question in the same request, skip childhood career and move probes, and do not continue a read-only turn when that question is already persisted. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -549,6 +549,96 @@ class EventProbesTest(unittest.TestCase):
|
||||
self.assertTrue(all(item["year"] >= 2018 for item in relationship))
|
||||
self.assertFalse(any(item["year"] in {2002, 2003} for item in relationship))
|
||||
|
||||
def test_career_and_relocation_boundaries_skip_childhood_years(self) -> None:
|
||||
from unittest.mock import patch
|
||||
|
||||
from scripts.rectification import event_probes as probes_mod
|
||||
|
||||
built = {
|
||||
"static_contexts": [
|
||||
_context("05:13", d4_asc=0, sun_house=4, sun_varga_sign=3, d10_asc=1, moon=100.0),
|
||||
_context("05:40", d4_asc=1, sun_house=10, sun_varga_sign=9, d10_asc=2, moon=101.0),
|
||||
]
|
||||
}
|
||||
|
||||
def fake_vim(_birth_date: str, moon: float, _lo: int, _hi: int) -> list[date]:
|
||||
early = [date(2005, 5, 15), date(2012, 11, 15), date(2019, 4, 15), date(2023, 5, 15)]
|
||||
late = [date(2005, 11, 15), date(2012, 5, 15), date(2019, 10, 15), date(2023, 11, 15)]
|
||||
return early if moon <= 100.0 else late
|
||||
|
||||
def fake_narayana(_asc: int, planets: dict, _birth_date: str, _lo: int, _hi: int) -> list[date]:
|
||||
moon = float(planets.get("Moon") or 0)
|
||||
return fake_vim(_birth_date, moon, _lo, _hi)
|
||||
|
||||
def fake_score(context: dict, *, birth_date: str, domain: str, year: int, month: int | None = None) -> dict:
|
||||
del birth_date, domain, year, month
|
||||
return {
|
||||
"rule_ids": ["vim_md_domain_house"]
|
||||
if probes_mod._context_time(context) == "05:13"
|
||||
else ["no_domain_activation"]
|
||||
}
|
||||
|
||||
with (
|
||||
patch.object(probes_mod, "_vim_start_dates", side_effect=fake_vim),
|
||||
patch.object(probes_mod, "_narayana_start_dates", side_effect=fake_narayana),
|
||||
patch.object(probes_mod, "_score_year", side_effect=fake_score),
|
||||
):
|
||||
probes = _probes(_request(), built, ["05:13", "05:40"], "05:13")
|
||||
|
||||
career = [item for item in probes if item["domain"] == "career"]
|
||||
relocation = [item for item in probes if item["domain"] == "relocation"]
|
||||
self.assertTrue(career)
|
||||
self.assertTrue(all(item["year"] >= 2019 for item in career))
|
||||
self.assertFalse(any(item["year"] in {2005, 2012} for item in career))
|
||||
self.assertTrue(relocation)
|
||||
self.assertTrue(all(item["year"] >= 2015 for item in relocation))
|
||||
self.assertFalse(any(item["year"] == 2005 for item in relocation))
|
||||
|
||||
def test_recorded_relationship_skips_adjacent_existence_year(self) -> None:
|
||||
from unittest.mock import patch
|
||||
|
||||
from scripts.rectification import event_probes as probes_mod
|
||||
|
||||
built = {
|
||||
"static_contexts": [
|
||||
_context("05:13", d4_asc=1, sun_house=4, sun_varga_sign=3, d9_asc=1, moon=100.0),
|
||||
_context("05:40", d4_asc=1, sun_house=4, sun_varga_sign=3, d9_asc=2, moon=101.0),
|
||||
]
|
||||
}
|
||||
request = _request(events=_gate_events() + [{
|
||||
"id": "00000000-0000-4000-8000-000000000021",
|
||||
"domain": "relationship",
|
||||
"event_kind": "relationship_start",
|
||||
"summary": "相识",
|
||||
"date": "2024-05-01",
|
||||
"precision": "month",
|
||||
}])
|
||||
|
||||
def fake_vim(_birth_date: str, moon: float, _lo: int, _hi: int) -> list[date]:
|
||||
return [date(2023, 5, 15), date(2019, 3, 15)] if moon <= 100.0 else [date(2023, 11, 15), date(2018, 9, 15)]
|
||||
|
||||
def fake_narayana(_asc: int, planets: dict, _birth_date: str, _lo: int, _hi: int) -> list[date]:
|
||||
moon = float(planets.get("Moon") or 0)
|
||||
return fake_vim(_birth_date, moon, _lo, _hi)
|
||||
|
||||
def fake_score(context: dict, *, birth_date: str, domain: str, year: int, month: int | None = None) -> dict:
|
||||
del birth_date, domain, month
|
||||
return {
|
||||
"rule_ids": ["vim_md_domain_house"]
|
||||
if probes_mod._context_time(context) == "05:13" and year != 2024
|
||||
else ["no_domain_activation"]
|
||||
}
|
||||
|
||||
with (
|
||||
patch.object(probes_mod, "_vim_start_dates", side_effect=fake_vim),
|
||||
patch.object(probes_mod, "_narayana_start_dates", side_effect=fake_narayana),
|
||||
patch.object(probes_mod, "_score_year", side_effect=fake_score),
|
||||
):
|
||||
probes = _probes(request, built, ["05:13", "05:40"], "05:13")
|
||||
|
||||
relationship = [item for item in probes if item["domain"] == "relationship"]
|
||||
self.assertFalse(any(item["year"] == 2023 for item in relationship))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user