mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-10-09 15:06:39 +00:00
fix: more messages say only what is certain
- Host restore notification: reports its tasks and no longer calls the node fully ready. - Watchdog notification: covers an application that did not start as well as one that stopped again. - OCI: Modify summary, Immich recognition preview, private network kept by another guest, empty USB list. - gzip diagnostic no longer says that nothing changed. Source questions from the Italian review by @f3rs3n.
This commit is contained in:
@@ -76,22 +76,28 @@ class BackupSplitTests(unittest.TestCase):
|
||||
self.assertEqual(result['title'], 'alias: Backup outcome unconfirmed')
|
||||
self.assertEqual(result['body'], 'The backup outcome is not confirmed.')
|
||||
|
||||
def test_restore_keeps_original_ready_line_and_success_icon_with_warnings(self):
|
||||
def test_restore_reports_its_tasks_without_calling_the_node_ready_and_keeps_the_success_icon(self):
|
||||
import json
|
||||
from pathlib import Path
|
||||
from notification_final_fixture import restore_event
|
||||
ready = {'en': 'The node is now fully ready to use.', 'de': 'Der Knoten ist nun vollständig einsatzbereit.', 'es': 'El nodo está listo para usarse.', 'fr': 'Le nœud est maintenant entièrement prêt à être utilisé.', 'it': "Il nodo è ora completamente pronto per l'uso.", 'pt': 'O nó agora está totalmente pronto para uso.', 'sk': 'Uzol je teraz úplne pripravený na použitie.', 'sv': 'Noden är nu helt redo att användas.'}
|
||||
messages = Path(__file__).resolve().parents[3] / 'AppImage/messages'
|
||||
first = {language: json.loads((messages / language / 'common.json').read_text())
|
||||
['runtime']['notifications']['templates']['system_restore_completed']['body'].split('\n')[0]
|
||||
for language in LANGUAGES}
|
||||
for warning in ('', 'missing module zfs'):
|
||||
event = restore_event(warning)
|
||||
for language in LANGUAGES:
|
||||
result = deliver(event['event_type'], event['data'], event['severity'], language)
|
||||
self.assertTrue(result['title'].startswith('✅ '))
|
||||
self.assertIn(ready[language], result['body'])
|
||||
self.assertIn(ready[language], result['text'])
|
||||
self.assertIn(first[language], result['body'])
|
||||
self.assertIn(first[language], result['text'])
|
||||
self.assertNotIn('fully ready', result['body'])
|
||||
self.assertIn('2m', result['text'])
|
||||
if warning:
|
||||
self.assertIn(warning, result['text'])
|
||||
quiet = deliver(event['event_type'], event['data'], event['severity'], language, quiet=True)
|
||||
self.assertIn('✅', quiet['body'])
|
||||
self.assertIn(' ' + ready[language], quiet['body'])
|
||||
self.assertIn(first[language], quiet['body'])
|
||||
self.assertIn('white-space:pre-wrap;', quiet['html'])
|
||||
|
||||
def test_spanish_outcome_and_restore_titles_are_capitalized_and_failure_is_exact(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ from notification_fixture import templates as actual_templates
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
SCRIPTS = ROOT / 'AppImage/scripts'
|
||||
CATALOG = ROOT / 'AppImage/messages/en/common.json'
|
||||
EXPECTED = {'system_restore_completed': {'body': 'Post-restore tasks completed in background.\n\nGuests applied: {guests}\nBind-mount stubs: {stubs}\nStale node dirs removed: {stale_nodes}\nComponents reinstalled: {components}\nDuration: {duration}\n{warnings_block}\nThe node is now fully ready to use.'}}
|
||||
EXPECTED = {'system_restore_completed': {'body': 'Post-restore tasks completed in background.\n\nGuest configurations copied: {guests}\nBind-mount stub directories created: {stubs}\nStale node dirs removed: {stale_nodes}\nComponents reinstalled: {components}\nDuration: {duration}\n{warnings_block}'}}
|
||||
|
||||
|
||||
def extract(path, name, owner=None, namespace=None):
|
||||
@@ -72,7 +72,7 @@ class OutcomeWording(unittest.TestCase):
|
||||
result = module.render_template('system_restore_completed', {
|
||||
'hostname':'node-a','guests':3,'stubs':0,'stale_nodes':0,
|
||||
'components':1,'duration':'2m','warnings_block':''}, 'es')
|
||||
self.assertIn('Guests aplicados: 3', result['body'])
|
||||
self.assertIn('Configuración de guests copiada: 3', result['body'])
|
||||
self.assertNotIn('invitados', result['body'].lower())
|
||||
|
||||
def test_settings_labels_stay_at_upstream_values_in_all_locales(self):
|
||||
@@ -345,7 +345,7 @@ class OutcomeWording(unittest.TestCase):
|
||||
restore = module.render_template('system_restore_completed', {'hostname':'node', 'guests':4,
|
||||
'stubs':1,'stale_nodes':2,'components':1,'duration':'2m','warnings_block':'Missing module'},lang)
|
||||
self.assertIn('Missing module',restore['body'])
|
||||
if lang == 'en': self.assertIn('fully ready',restore['body'].lower())
|
||||
if lang == 'en': self.assertNotIn('fully ready',restore['body'].lower())
|
||||
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ class OutcomeWording(unittest.TestCase):
|
||||
self.assertEqual(event['severity'], 'WARNING' if warnings else 'INFO')
|
||||
result = self.render(event['event_type'], event['data'], 'en')
|
||||
self.assertIn('Post-restore tasks completed', result['body'])
|
||||
self.assertIn('fully ready', result['body'])
|
||||
self.assertNotIn('fully ready', result['body'])
|
||||
if warnings: self.assertIn('missing modules', result['body'])
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class PVE92Tests(unittest.TestCase):
|
||||
with self.subTest(event=event, field=field):
|
||||
value = slovak['templates'][event][field]
|
||||
result = templates.render_template(event, data, 'sk')
|
||||
self.assertEqual(result[field], value.format(**data))
|
||||
self.assertEqual(result[field].strip(), value.format(**data).strip())
|
||||
self.assertNotIn(value, (SCRIPTS / 'notification_templates.py').read_text())
|
||||
# Independently updated and absent leaves use the usual provider.
|
||||
import copy
|
||||
|
||||
@@ -49,3 +49,23 @@ class OutcomePromises(TestCase):
|
||||
for key in ('deleteAttached', 'storageAttached'):
|
||||
self.assertEqual(texts[key].count('{ids}'), 1, f'{locale} {key}')
|
||||
self.assertEqual(texts['disableBody'].count('. '), 1, f'{locale} disableBody')
|
||||
|
||||
def test_the_host_restore_notice_reports_tasks_and_does_not_call_the_node_ready(self):
|
||||
for locale in LOCALES:
|
||||
body = json.loads((ROOT / f'AppImage/messages/{locale}/common.json').read_text())['runtime']['notifications']['templates']['system_restore_completed']['body']
|
||||
self.assertEqual(body.split('\n')[-1], '{warnings_block}', locale)
|
||||
self.assertEqual(body.count('\n'), 7, locale)
|
||||
|
||||
def test_the_watchdog_failure_covers_an_application_that_did_not_start(self):
|
||||
english = json.loads((ROOT / 'AppImage/messages/en/common.json').read_text())['runtime']['notifications']['templates']['oci_watchdog_failed']
|
||||
self.assertNotIn('keeps stopping', english['title'] + english['body'] + english['label'])
|
||||
self.assertIn('did not start', english['body'])
|
||||
|
||||
def test_other_wording_that_promised_too_much(self):
|
||||
texts = oci_menu_texts()
|
||||
self.assertIn('Private network kept, because other guests still use it:', texts)
|
||||
recreation = (ROOT / 'oci/src/proxmenux_oci/stack_recreation.py').read_text()
|
||||
self.assertNotIn('if anything fails', recreation)
|
||||
self.assertIn('a stopped one is left stopped', recreation)
|
||||
for script in ('scripts/post_install/customizable_post_install.sh', 'scripts/post_install/uninstall-tools.sh'):
|
||||
self.assertNotIn('leaving it unchanged', (ROOT / script).read_text(), script)
|
||||
|
||||
Reference in New Issue
Block a user