(refactor) Use operator-facing config errors

Replace remaining model-name based configuration errors with labels that
match the Django-first operating model.

Add coverage for missing global config and host configuration errors so
operator-facing messages stay readable.
This commit is contained in:
2026-05-21 02:56:00 +02:00
parent 1c8cbd96ca
commit a73d34ac9f
3 changed files with 13 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from django.test import TestCase
from pobsync_backend.config_repository import global_config_data, host_config_data
from pobsync_backend.config_repository import ConfigRepositoryError, global_config_data, host_config_data
from pobsync_backend.models import GlobalConfig, HostConfig
@@ -52,3 +52,12 @@ class ConfigRepositoryTests(TestCase):
self.assertEqual(host_cfg["excludes_add"], ["/tmp/***"])
self.assertNotIn("unknown", global_cfg)
self.assertNotIn("unknown", host_cfg)
def test_missing_config_errors_use_operator_labels(self) -> None:
with self.assertRaisesMessage(ConfigRepositoryError, "Missing global config 'default'"):
global_config_data()
GlobalConfig.objects.create(name="default", backup_root="/backups")
with self.assertRaisesMessage(ConfigRepositoryError, "Missing enabled host 'web-01'"):
host_config_data("web-01")