修复测试:AMSC/NMC 用 monkeypatch.setattr 替换模块级常量
This commit is contained in:
@@ -74,7 +74,8 @@ def test_parse_wind_plate_payload_rejects_unauthorized_or_empty_payloads():
|
|||||||
|
|
||||||
|
|
||||||
def test_fetch_amsc_official_current_uses_domestic_city_whitelist(monkeypatch):
|
def test_fetch_amsc_official_current_uses_domestic_city_whitelist(monkeypatch):
|
||||||
monkeypatch.setenv("AMSC_AWOS_BASE_URL", "https://www.amsc.net.cn/gateway/api/saas/rest/amc/AwosController/getWindPlate")
|
import src.data_collection.amsc_awos_sources as _amsc
|
||||||
|
monkeypatch.setattr(_amsc, "AMSC_AWOS_BASE_URL", "https://www.amsc.net.cn/gateway/api/saas/rest/amc/AwosController/getWindPlate")
|
||||||
assert _amsc_supported_city_codes()["beijing"] == "ZBAA"
|
assert _amsc_supported_city_codes()["beijing"] == "ZBAA"
|
||||||
assert "new york" not in _amsc_supported_city_codes()
|
assert "new york" not in _amsc_supported_city_codes()
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class _DummyCollector(NmcSourceMixin):
|
|||||||
|
|
||||||
|
|
||||||
def test_fetch_nmc_region_current_parses_rest_payload(monkeypatch):
|
def test_fetch_nmc_region_current_parses_rest_payload(monkeypatch):
|
||||||
monkeypatch.setenv("NMC_REALTIME_BASE_URL", "https://www.nmc.cn/rest/real")
|
import src.data_collection.nmc_sources as _nmc
|
||||||
|
monkeypatch.setattr(_nmc, "_NMC_REALTIME_BASE", "https://www.nmc.cn/rest/real")
|
||||||
collector = _DummyCollector(
|
collector = _DummyCollector(
|
||||||
{
|
{
|
||||||
"https://www.nmc.cn/rest/real/atcMf": _DummyResponse(
|
"https://www.nmc.cn/rest/real/atcMf": _DummyResponse(
|
||||||
@@ -72,7 +73,8 @@ def test_fetch_nmc_region_current_parses_rest_payload(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_fetch_nmc_official_nearby_returns_normalized_row(monkeypatch):
|
def test_fetch_nmc_official_nearby_returns_normalized_row(monkeypatch):
|
||||||
monkeypatch.setenv("NMC_REALTIME_BASE_URL", "https://www.nmc.cn/rest/real")
|
import src.data_collection.nmc_sources as _nmc
|
||||||
|
monkeypatch.setattr(_nmc, "_NMC_REALTIME_BASE", "https://www.nmc.cn/rest/real")
|
||||||
collector = _DummyCollector(
|
collector = _DummyCollector(
|
||||||
{
|
{
|
||||||
"https://www.nmc.cn/rest/real/atcMf": _DummyResponse(
|
"https://www.nmc.cn/rest/real/atcMf": _DummyResponse(
|
||||||
|
|||||||
Reference in New Issue
Block a user