mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-01 10:22:08 +00:00
- A health problem of a VM or CT names the guest in its title and in the Quiet Hours summary; a recovery shows its category by name in the reader's language. - AI model lists reviewed against each provider: Gemini adds 3.6/3.7/3.8 Flash, Groq adds gpt-oss-120b, and Groq/OpenRouter models no longer served are removed. - OCI installer proposes the volume choice the recipe declares, so a path meant for a host directory is proposed as one; Duplicati /source is proposed on a host directory.
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
"""A health problem of a VM or CT names the guest in its title, and health
|
|
categories are shown by their name, not by their internal key."""
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
SCRIPTS_DIR = Path(__file__).resolve().parents[1]
|
|
if str(SCRIPTS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
import notification_templates as templates
|
|
|
|
QMP = {'category': 'vms', 'severity': 'WARNING', 'error_key': 'vm_101',
|
|
'reason': 'VM 101 (web): QMP command failed or timed out.',
|
|
'id': '101', 'vmname': 'web', 'type': 'VM'}
|
|
|
|
|
|
class VmHealthTitleTests(unittest.TestCase):
|
|
def setUp(self):
|
|
patcher = mock.patch.object(templates, '_get_hostname', return_value='pve')
|
|
patcher.start()
|
|
self.addCleanup(patcher.stop)
|
|
|
|
def test_a_guest_problem_names_the_guest(self):
|
|
title = templates.render_template('system_problem', dict(QMP))['title']
|
|
self.assertEqual(title, 'pve: System problem detected — VM 101 (web)')
|
|
|
|
def test_a_container_without_a_name_is_named_by_its_id(self):
|
|
data = dict(QMP, id='105', vmname='', type='CT')
|
|
self.assertTrue(templates.render_template('system_problem', data)['title'].endswith('— CT 105'))
|
|
|
|
def test_the_recovery_names_the_category_and_the_guest(self):
|
|
data = dict(QMP, severity='OK', original_severity='WARNING', duration='6m', is_recovery=True)
|
|
title = templates.render_template('error_resolved', data)['title']
|
|
self.assertEqual(title, 'pve: Resolved - VMs and containers — VM 101 (web)')
|
|
|
|
def test_the_category_follows_the_language_of_the_reader(self):
|
|
data = dict(QMP, severity='OK', original_severity='WARNING', duration='6m', is_recovery=True)
|
|
title = templates.render_template('error_resolved', data, 'es')['title']
|
|
self.assertIn('Máquinas virtuales y contenedores', title)
|
|
self.assertNotIn(' vms', title)
|
|
|
|
def test_a_category_without_a_name_keeps_its_key(self):
|
|
data = {'category': 'temperature', 'severity': 'OK', 'reason': 'Back to normal',
|
|
'original_severity': 'WARNING', 'duration': '3m', 'is_recovery': True}
|
|
self.assertIn('Resolved - temperature', templates.render_template('error_resolved', data)['title'])
|
|
|
|
def test_other_events_with_an_id_are_not_given_a_guest(self):
|
|
data = {'category': 'storage', 'severity': 'WARNING', 'reason': 'x', 'id': '7', 'type': 'VM'}
|
|
self.assertNotIn('VM 7', templates.render_template('system_problem', data)['title'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|