This commit is contained in:
Mateusz Gruszczyński
2026-08-15 23:43:58 +02:00
parent 71b6c0d86f
commit e8e5515e24
27 changed files with 861 additions and 64 deletions
+23
View File
@@ -0,0 +1,23 @@
import os
import unittest
from unittest.mock import patch
from app.config import Config
class ConfigTests(unittest.TestCase):
def test_rule_update_interval_defaults_to_24_hours(self):
with patch.dict(os.environ, {}, clear=True):
self.assertEqual(Config.from_env().rule_update_interval_hours, 24)
def test_rule_update_interval_can_be_changed_or_disabled(self):
with patch.dict(os.environ, {"RULE_UPDATE_INTERVAL_HOURS": "6"}, clear=True):
self.assertEqual(Config.from_env().rule_update_interval_hours, 6)
with patch.dict(os.environ, {"RULE_UPDATE_INTERVAL_HOURS": "0"}, clear=True):
self.assertEqual(Config.from_env().rule_update_interval_hours, 0)
with patch.dict(os.environ, {"RULE_UPDATE_INTERVAL_HOURS": "-5"}, clear=True):
self.assertEqual(Config.from_env().rule_update_interval_hours, 0)
if __name__ == "__main__":
unittest.main()