43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""Tests for WeCom delta mode."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from daily.config import (
|
|
delta_baseline_fallback,
|
|
env_bool,
|
|
force_push,
|
|
news_dedup_days,
|
|
skip_push_when_silent,
|
|
wecom_mode,
|
|
)
|
|
|
|
|
|
class ConfigHelpersTests(unittest.TestCase):
|
|
def test_wecom_mode_defaults_delta(self):
|
|
with patch.dict(os.environ, {}, clear=True):
|
|
self.assertEqual(wecom_mode(), "delta")
|
|
|
|
def test_wecom_mode_full(self):
|
|
with patch.dict(os.environ, {"DAILY_WECOM_MODE": "full"}, clear=True):
|
|
self.assertEqual(wecom_mode(), "full")
|
|
|
|
def test_env_bool_truthy(self):
|
|
with patch.dict(os.environ, {"DAILY_FORCE_PUSH": "1"}, clear=True):
|
|
self.assertTrue(env_bool("DAILY_FORCE_PUSH", False))
|
|
|
|
def test_skip_push_when_silent_default(self):
|
|
with patch.dict(os.environ, {}, clear=True):
|
|
self.assertTrue(skip_push_when_silent())
|
|
|
|
def test_news_dedup_days_default(self):
|
|
with patch.dict(os.environ, {}, clear=True):
|
|
self.assertEqual(news_dedup_days(), 7)
|
|
|
|
def test_delta_baseline_fallback_default(self):
|
|
with patch.dict(os.environ, {}, clear=True):
|
|
self.assertEqual(delta_baseline_fallback(), "full")
|