fix: restore category news collection
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
CRAWLER = ROOT / "docker" / "crawler"
|
||||
|
||||
|
||||
class NewsCollectionRegressionTest(unittest.TestCase):
|
||||
def read(self, name: str) -> str:
|
||||
return (CRAWLER / name).read_text(encoding="utf-8")
|
||||
|
||||
def test_lottery_sources_use_runtime_month(self):
|
||||
hkjc = self.read("hkjc_lottery_news.py")
|
||||
taiwan = self.read("taiwan_lottery_news.py")
|
||||
|
||||
self.assertNotIn("?ny=2026&nm=6", hkjc)
|
||||
self.assertIn("LIST_URL_TEMPLATE", hkjc)
|
||||
self.assertIn("def build_list_url", hkjc)
|
||||
self.assertNotIn("from=2025-06&to=2026-06", taiwan)
|
||||
self.assertIn("LIST_API_TEMPLATE", taiwan)
|
||||
self.assertIn("def build_list_api", taiwan)
|
||||
|
||||
def test_general_lottery_task_is_registered(self):
|
||||
tasks = (ROOT / "docker" / "crawler" / "config" / "crawler_tasks.yaml").read_text(encoding="utf-8")
|
||||
block_start = tasks.index(" - key: lottery_news")
|
||||
block = tasks[block_start : tasks.find("\n - key:", block_start + 1)]
|
||||
self.assertIn("action: lottery_news", block)
|
||||
self.assertIn("active: true", block)
|
||||
|
||||
def test_content_queue_filters_non_publishable_body_not_visibility(self):
|
||||
source = self.read("article_fetcher.py")
|
||||
self.assertNotIn("OR is_show = 0", source)
|
||||
self.assertIn("NOT REGEXP", source)
|
||||
self.assertIn("MAX_RETRY = 4", source)
|
||||
|
||||
def test_rss_categories_allow_summary_to_be_listed(self):
|
||||
for name in ("lottery_news.py", "crypto_news.py", "nba_news.py", "cba_news.py"):
|
||||
source = self.read(name)
|
||||
self.assertIn("allow_summary=True", source, name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user