File indexing completed on 2026-09-01 09:34:24
0001 from types import SimpleNamespace
0002 from unittest.mock import patch
0003
0004 from django.test import SimpleTestCase
0005
0006 from monitor_app.notice_router import _compose
0007
0008
0009 class NoticeCompositionTests(SimpleTestCase):
0010 @patch('monitor_app.models.external_face_base_url',
0011 return_value='https://monitor.example')
0012 def test_operation_and_subject_label_replace_internal_batch_id(self, _base):
0013 row = SimpleNamespace(id=42, funcname='event')
0014 notice = _compose(row, {
0015 'action': 'panda_task_operation',
0016 'operation': 'resume',
0017 'subject_key': '03cae1f8-4fb2-4493-a80e-f1e67f1d985b',
0018 'subject_label': 'PanDA tasks 38941, 38942',
0019 'outcome': 'ok',
0020 'summary': '2/2 verified',
0021 'url': '/panda/tasks/',
0022 })
0023
0024 self.assertEqual(notice['title'],
0025 'resume: PanDA tasks 38941, 38942')
0026 self.assertEqual(notice['detail'], '2/2 verified')
0027 self.assertEqual(notice['url'],
0028 'https://monitor.example/prod/panda/tasks/')