From a527f14a57026dfdd14bf1cc25a923f8b57d941a Mon Sep 17 00:00:00 2001 From: Agents AI Date: Mon, 20 Jul 2026 09:18:05 +0900 Subject: [PATCH] =?UTF-8?q?signal=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=AEimport=E6=BC=8F=E3=82=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 1 + tests/test_app.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app.py b/app.py index 697b9b2..b8fef52 100644 --- a/app.py +++ b/app.py @@ -14,6 +14,7 @@ import logging import requests from datetime import datetime, timezone from typing import Dict, List, Optional +import signal import threading from http.server import HTTPServer, BaseHTTPRequestHandler from dataclasses import dataclass diff --git a/tests/test_app.py b/tests/test_app.py index 2128760..e9098b6 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,4 +1,8 @@ import os +import signal + +import app + import unittest from unittest.mock import Mock, patch @@ -152,5 +156,23 @@ class EmailMonitorNotificationTests(unittest.TestCase): mark_read.assert_called_once_with("42") +class ApplicationStartupTests(unittest.TestCase): + @patch.dict(os.environ, {**EMAIL_ENV, "DISCORD_WEBHOOK_URL": "https://discord.example/webhook"}, clear=True) + @patch("app.run_http_server") + @patch("app.threading.Thread") + @patch("app.signal.signal") + def test_main_registers_signal_handlers_and_starts_services( + self, register_signal, thread_class, run_http_server + ): + monitor_thread = thread_class.return_value + + app.main() + + registered_signals = [call.args[0] for call in register_signal.call_args_list] + self.assertEqual(registered_signals, [signal.SIGINT, signal.SIGTERM]) + monitor_thread.start.assert_called_once_with() + run_http_server.assert_called_once_with() + + if __name__ == "__main__": unittest.main() -- 2.52.0