fix(r5): address the second /code-review high round — 7 findings
- the volume keys no longer defer to a scrollable card while in fullscreen
(mirrored into a ref: the keydown handler is bound once and state would be stale)
- the debounced volume flush writes straight to storage; persisting inside a
setState updater is not guaranteed to run for an unmounting component
- the HLS sweep also matches the original {key}_{start} directory naming, which
is what the oldest leftovers on disk actually use
- run_rss_poll returns {new, failed} so an egress outage stops rendering as
"ok — 0" in the scheduler card and the audit log; /api/sync/rss reports it too
- drop the unused poll_rss_channel (it silently gained a new exception)
- _Breaker.run is generic, so a call site keeps its item-id type
- test helper instead of the generator-throw idiom
This commit is contained in:
@@ -51,6 +51,11 @@ class TestBreaker:
|
||||
assert not b.open()
|
||||
|
||||
|
||||
def _quota_dead():
|
||||
"""A write op that fails the way a quota-exhausted / scope-revoked account fails."""
|
||||
raise YouTubeError("quota exceeded")
|
||||
|
||||
|
||||
class TestBreakerRun:
|
||||
def test_returns_the_ops_result_and_leaves_failures_alone(self):
|
||||
b, failed = _Breaker(), []
|
||||
@@ -59,22 +64,25 @@ class TestBreakerRun:
|
||||
|
||||
def test_a_youtube_error_records_the_failure_and_counts_towards_the_trip(self):
|
||||
b, failed = _Breaker(limit=2), []
|
||||
assert b.run(lambda: (_ for _ in ()).throw(YouTubeError("quota")), lambda: failed.append("v1")) is FAILED
|
||||
assert b.run(_quota_dead, lambda: failed.append("v1")) is FAILED
|
||||
assert failed == ["v1"] and b.open()
|
||||
b.run(lambda: (_ for _ in ()).throw(YouTubeError("quota")), lambda: failed.append("v2"))
|
||||
b.run(_quota_dead, lambda: failed.append("v2"))
|
||||
assert not b.open()
|
||||
|
||||
def test_a_tripped_breaker_never_calls_the_op(self):
|
||||
b, failed, calls = _Breaker(limit=1), [], []
|
||||
b.run(lambda: (_ for _ in ()).throw(YouTubeError("quota")), lambda: failed.append("v1"))
|
||||
b.run(_quota_dead, lambda: failed.append("v1"))
|
||||
assert b.run(lambda: calls.append("called"), lambda: failed.append("v2")) is FAILED
|
||||
assert calls == [] # the whole point: no more quota spent
|
||||
assert failed == ["v1", "v2"] # …but the item is still reported
|
||||
|
||||
def test_other_exceptions_are_not_swallowed(self):
|
||||
# Only YouTubeError is a "write failed" signal; a bug must still surface.
|
||||
def boom():
|
||||
raise ValueError("bug")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
_Breaker().run(lambda: (_ for _ in ()).throw(ValueError("bug")), lambda: None)
|
||||
_Breaker().run(boom, lambda: None)
|
||||
|
||||
|
||||
class TestRssErrorVsEmpty:
|
||||
|
||||
Reference in New Issue
Block a user