fix(misc): CSV column name mismatches in data loading (#32)

* fix: CSV column name mismatches in data loading

- sect.py: Fix headquarter_name/headquarter_desc -> name/desc when reading sect_region.csv
- sect.py: Move sid initialization before technique lookup to fix unbound variable bug
- technique.py: Change sect (name) to sect_id (int) to match technique.csv column
- elixir.py: Remove redundant get_int(row, "id") that reads non-existent column

These fixes ensure:
1. Sect headquarters display correct location names (e.g., "大千光极城" instead of "不夜城")
2. Sect techniques are correctly associated and displayed
3. Technique sect restrictions work properly

* fix: update main.py to use sect_id, add CSV loading tests

- main.py: Change technique.sect to technique.sect_id in API response
- Add tests/test_csv_loading.py to verify CSV column names match code

* test: add API test for /api/meta/game_data endpoint

Verify that techniques in API response use sect_id field (not sect)

* fix: add None check for hq_region in AvatarFactory

Remove redundant code that adds sect headquarters to known_regions.
This logic is already handled by Avatar._init_known_regions() which
uses sect_id matching (more reliable than name-based lookup).

The removed code was causing a flaky test (~1% failure rate) because
resolve_query returns None in test environments with simplified maps.
This commit is contained in:
Zihao Xu
2026-01-17 23:31:15 -08:00
committed by GitHub
parent 0acf72a313
commit 7edae9188b
6 changed files with 178 additions and 28 deletions

View File

@@ -459,12 +459,6 @@ class AvatarFactory:
# 自己.relations[师傅] = MASTER (自己认为师傅是师傅)
plan.master_avatar.set_relation(avatar, Relation.APPRENTICE)
# 宗门弟子天生知道宗门总部位置
if avatar.sect is not None:
res = resolve_query(avatar.sect.headquarter.name, world, expected_types=[Region])
hq_region = res.obj
avatar.known_regions.add(hq_region.id)
if avatar.technique is not None:
mapped = attribute_to_root(avatar.technique.attribute)
if mapped is not None: