@@ -32,11 +32,22 @@ def snapshot():
3232 )
3333
3434
35+ def _increment_persist_counter (counter ):
36+ def _increment (_snapshot ):
37+ counter ["persist" ] += 1
38+
39+ return _increment
40+
41+
42+ def _raise_should_not_persist (_snapshot ):
43+ raise RuntimeError ("should not persist" )
44+
45+
3546def test_manual_refresh_returns_accepted (client , snapshot , monkeypatch ):
3647 calls = {"persist" : 0 }
3748 monkeypatch .setattr (
3849 "app.rates.routes.persist_snapshot" ,
39- lambda snapshot : calls . __setitem__ ( "persist" , calls [ "persist" ] + 1 ),
50+ _increment_persist_counter ( calls ),
4051 )
4152
4253 app = client .application
@@ -61,7 +72,7 @@ def test_manual_refresh_returns_accepted(client, snapshot, monkeypatch):
6172def test_manual_refresh_throttles_requests (client , snapshot , monkeypatch ):
6273 monkeypatch .setattr (
6374 "app.rates.routes.persist_snapshot" ,
64- lambda snapshot : ( _ for _ in ()). throw ( RuntimeError ( "should not persist" )) ,
75+ _raise_should_not_persist ,
6576 )
6677
6778 app = client .application
@@ -77,7 +88,7 @@ def test_manual_refresh_throttles_requests(client, snapshot, monkeypatch):
7788
7889
7990def test_manual_refresh_reports_provider_error (client , monkeypatch ):
80- monkeypatch .setattr ("app.rates.routes.persist_snapshot" , lambda snapshot : None )
91+ monkeypatch .setattr ("app.rates.routes.persist_snapshot" , lambda _snapshot : None )
8192
8293 app = client .application
8394 app .extensions ["fx_orchestrator" ] = DummyOrchestrator (error = ProviderError ("primary down" ))
@@ -94,7 +105,7 @@ def test_manual_refresh_respects_zero_throttle(client, snapshot, monkeypatch):
94105 calls = {"persist" : 0 }
95106 monkeypatch .setattr (
96107 "app.rates.routes.persist_snapshot" ,
97- lambda snapshot : calls . __setitem__ ( "persist" , calls [ "persist" ] + 1 ),
108+ _increment_persist_counter ( calls ),
98109 )
99110
100111 app = client .application
0 commit comments