fix: 拆除后工参改用拆除日下一周的周一

停闭后一周的指标周三就有、下一周周一的工参周四才取,中间这一天周边站先按拆除前工参算,并在结果说明里写明。
This commit is contained in:
2026-11-12 14:57:19 +08:00
parent 62b72bb130
commit 9225d7e45b
7 changed files with 32 additions and 23 deletions
+5 -2
View File
@@ -198,8 +198,8 @@ def test_evaluate_site_finds_neighbors_and_sectors_with_mock_sources():
group = groups[0]
stages: list[str] = []
payload = evaluate_site(group, "江门", TODAY, MockGongcan(), MockMetrics(), stage=stages.append)
# 拆除前工参是拆除日上一周的周一,拆除后工参是拆除日当周的周一。
assert payload["beforeDay"] == "2026-10-05" and payload["afterDay"] == "2026-10-12" and payload["afterPresent"] is True
# 拆除前工参是拆除日上一周的周一,拆除后工参是拆除日下一周的周一。
assert payload["beforeDay"] == "2026-10-05" and payload["afterDay"] == "2026-10-19" and payload["afterPresent"] is True
assert len(payload["neighbors"]) == 3 and payload["locatable"]
assert all(item["site"] != "模拟待拆站点" for item in payload["item2"])
assert not {"460-00-5001-1", "460-00-5001-2"} & {item["cgi"] for item in payload["item2"]}
@@ -231,6 +231,9 @@ def test_evaluate_site_waits_for_weeks_the_platform_has_not_synced():
last_week = evaluate_site(low_site(date(2026, 11, 4)), "江门", TODAY, MockGongcan(), MockMetrics())
assert last_week["windows"]["after"] == ["2026-11-02", "2026-11-08"] and last_week["mrMonths"] == {"before": "2026-10", "after": None}
assert any("停闭后的 4G MR 用 2026-11 的月数据" in note and "2026-12-03" in note for note in last_week["notes"])
# 停闭后一周的指标今天(周三)有了,下一周周一 11-09 的工参明天才取。
assert last_week["afterDay"] is None and "拆除后工参用 2026-11-09 的,要到 2026-11-12 才取,周边站先按拆除前工参算" in last_week["notes"]
assert not any("拆除后工参用" in note for note in done["notes"] + this_week["notes"])
lte_rows = [item for item in last_week["item2"] if item["tech"] == "4G"]
assert last_week["mrPending"] is True and not done["mrPending"]
assert all(item["before"]["mr_weak_pct"] is not None and item["after"]["mr_weak_pct"] is None and item["after"]["traffic_gb"] is not None for item in lte_rows)
+12 -11
View File
@@ -259,7 +259,7 @@ def test_next_to_fill_takes_one_at_a_time_and_backs_off_after_a_failure():
assert platform.fetched == [date(2026, 11, 2), date(2026, 10, 26)]
# 拆除日 2026-10-15 是周四:上一周的周一是 10-05,当周的周一是 10-12。
# 拆除日 2026-10-15 是周四:上一周的周一是 10-05,下一周的周一是 10-19。
REMOVAL = date(2026, 10, 15)
TODAY = date(2026, 11, 12)
@@ -303,21 +303,22 @@ def test_before_uses_latest_available_monday_for_a_future_removal():
assert platform.fetched == []
def test_after_is_the_monday_of_the_removal_week_and_target_may_still_be_there():
platform = Platform({date(2026, 10, 12): with_target()})
store = make_store(platform, {date(2026, 10, 19): without_target()})
assert asyncio.run(pick_after(store, CITY, SITE, REMOVAL, TODAY)) == AfterPick(date(2026, 10, 12), True)
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 10, 19), TODAY)) == AfterPick(date(2026, 10, 19), False)
assert platform.fetched == [date(2026, 10, 12)]
def test_after_is_the_monday_after_the_removal_week_and_target_may_still_be_there():
platform = Platform({date(2026, 10, 19): with_target()})
store = make_store(platform, {date(2026, 10, 12): with_target(), date(2026, 10, 26): without_target()})
assert asyncio.run(pick_after(store, CITY, SITE, REMOVAL, TODAY)) == AfterPick(date(2026, 10, 19), True)
# 拆除日正好是周一,也用下一周的周一。
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 10, 19), TODAY)) == AfterPick(date(2026, 10, 26), False)
assert platform.fetched == [date(2026, 10, 19)]
def test_after_is_empty_until_that_monday_can_be_fetched():
store = make_store(Platform({}))
# 11-09 这个周一 11-12 起可取;11-16 的还不行。
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 10), date(2026, 11, 11))) is None
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 17), TODAY)) is None
# 拆除日 11-03 的下一周周一是 11-09,11-12 起可取;拆除日 11-10 的是 11-16,还不行。
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 3), date(2026, 11, 11))) is None
assert asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 10), TODAY)) is None
with pytest.raises(GongcanError, match="平台没有这一天"):
asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 10), TODAY))
asyncio.run(pick_after(store, CITY, SITE, date(2026, 11, 3), TODAY))
def test_target_needs_cgis_or_site():