fix: expose match live stream task error on failure
This commit is contained in:
@@ -8,7 +8,12 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from match_live_stream import _build_detail_url, choose_next_fetch_at, parse_match_live_detail_html
|
||||
from match_live_stream import (
|
||||
_build_detail_url,
|
||||
_build_run_result,
|
||||
choose_next_fetch_at,
|
||||
parse_match_live_detail_html,
|
||||
)
|
||||
|
||||
|
||||
class MatchLiveStreamTest(unittest.TestCase):
|
||||
@@ -65,6 +70,17 @@ class MatchLiveStreamTest(unittest.TestCase):
|
||||
"https://json.ncctrials.com/room/7988511/detail.json?v=123456",
|
||||
)
|
||||
|
||||
def test_build_run_result_exposes_top_level_error_for_partial_failure(self):
|
||||
result = _build_run_result(candidate_count=3, success_count=2, failed_count=1)
|
||||
|
||||
self.assertFalse(result["success"])
|
||||
self.assertEqual(result["candidate_count"], 3)
|
||||
self.assertEqual(result["saved_count"], 2)
|
||||
self.assertEqual(result["count"], 2)
|
||||
self.assertEqual(result["failed_count"], 1)
|
||||
self.assertIn("失败 1 条", result["summary_text"])
|
||||
self.assertEqual(result["error"], "赛事直播流抓取存在失败线路: 失败 1 条")
|
||||
|
||||
def test_choose_next_fetch_at_uses_60s_for_empty_streams(self):
|
||||
self.assertEqual(choose_next_fetch_at(now_ts=1000, has_existing_stream=False), 1060)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user