fix(rectification): show the house table and hide the activity fold
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import unittest
|
||||
|
||||
from scripts.rectification.house_table import compact_house_table, compact_house_table_from_contexts
|
||||
|
||||
|
||||
class RectificationHouseTableTests(unittest.TestCase):
|
||||
def test_compact_house_table_is_twelve_houses_without_coordinates(self):
|
||||
chart = {
|
||||
"ascendant": {"sign": "Taurus"},
|
||||
"planets": {
|
||||
"Sun": {"sign": "Taurus", "house": 1, "lon": 41.2},
|
||||
"Moon": {"sign": "Cancer", "house": 3},
|
||||
"Mars": {"sign": "Aries", "house": 12},
|
||||
},
|
||||
}
|
||||
table = compact_house_table(chart, time="05:13")
|
||||
self.assertIsNotNone(table)
|
||||
assert table is not None
|
||||
self.assertEqual(table["time"], "05:13")
|
||||
self.assertEqual(table["lagna"], "金牛座")
|
||||
self.assertEqual(len(table["houses"]), 12)
|
||||
self.assertEqual(table["houses"][0], {
|
||||
"house": 1,
|
||||
"sign": "金牛座",
|
||||
"occupants": ["太阳"],
|
||||
})
|
||||
self.assertEqual(table["houses"][2]["occupants"], ["月亮"])
|
||||
self.assertEqual(table["houses"][11]["occupants"], ["火星"])
|
||||
serialized = json.dumps(table, ensure_ascii=False)
|
||||
for denied in ("lon", "latitude", "longitude", "degree", "score", "fingerprint"):
|
||||
self.assertNotIn(denied, serialized)
|
||||
|
||||
def test_contexts_select_the_representative_time(self):
|
||||
table = compact_house_table_from_contexts(
|
||||
[
|
||||
{
|
||||
"feature": {"time": "05:12"},
|
||||
"chart": {"ascendant": {"sign": "Aries"}, "planets": {}},
|
||||
},
|
||||
{
|
||||
"feature": {"time": "05:13"},
|
||||
"chart": {
|
||||
"ascendant": {"sign": "Taurus"},
|
||||
"planets": {"Sun": {"sign": "Taurus", "house": 1}},
|
||||
},
|
||||
},
|
||||
],
|
||||
"05:13",
|
||||
)
|
||||
self.assertIsNotNone(table)
|
||||
assert table is not None
|
||||
self.assertEqual(table["lagna"], "金牛座")
|
||||
self.assertEqual(table["houses"][0]["occupants"], ["太阳"])
|
||||
|
||||
def test_missing_chart_stays_omitted(self):
|
||||
self.assertIsNone(compact_house_table_from_contexts([], "05:13"))
|
||||
self.assertIsNone(compact_house_table({"planets": {}}, time="05:13"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user