Compare commits
2 Commits
62dc0a0cd5
...
a1bdb2576d
| Author | SHA1 | Date | |
|---|---|---|---|
| a1bdb2576d | |||
| a527f14a57 |
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user