fix: isolate on-chain provider outages
This commit is contained in:
@@ -108,6 +108,21 @@ def test_partial_fast_scrape_preserves_last_known_good_metric(server, monkeypatc
|
||||
assert saved["fear_greed"]["source"] == "alternative.me"
|
||||
|
||||
|
||||
def test_onchain_sources_fail_independently(server, monkeypatch):
|
||||
fake_lib = types.ModuleType("scrapers.lookintobitcoin")
|
||||
setattr(fake_lib, "scrape_all", lambda: (_ for _ in ()).throw(RuntimeError("LIB down")))
|
||||
fake_coc = types.ModuleType("scrapers.checkonchain")
|
||||
setattr(fake_coc, "scrape_all", lambda: {"sopr": {"value": 0.99}})
|
||||
monkeypatch.setitem(sys.modules, "scrapers.lookintobitcoin", fake_lib)
|
||||
monkeypatch.setitem(sys.modules, "scrapers.checkonchain", fake_coc)
|
||||
|
||||
observations, errors, successful_sources = server._scrape_onchain_sources()
|
||||
|
||||
assert observations["sopr"]["value"] == 0.99
|
||||
assert successful_sources == 1
|
||||
assert any("LookIntoBitcoin" in error for error in errors)
|
||||
|
||||
|
||||
def test_expired_onchain_timestamp_triggers_real_refresh(server, monkeypatch, tmp_path):
|
||||
old = datetime.now(timezone.utc) - timedelta(hours=7)
|
||||
cache_path = tmp_path / "cache.json"
|
||||
|
||||
Reference in New Issue
Block a user