From 00a44f76217f1fdf472bc7e6701f84adf1fc1dc6 Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 21 Nov 2026 20:17:13 +0300 Subject: [PATCH] fix(interfaces): a link state libvirt reports as unknown is said in words libvirt names an unknown link state "unknown", which the interfaces page showed as "Link unknown" in English in every language. It is now the translated "Link unknown", as when there is no state. --- interfaces/templates/link_badge.html | 2 +- interfaces/tests/test_views.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/interfaces/templates/link_badge.html b/interfaces/templates/link_badge.html index d48afb0c..b0df238b 100644 --- a/interfaces/templates/link_badge.html +++ b/interfaces/templates/link_badge.html @@ -1 +1 @@ -{% load i18n %}{# a link state as libvirt reports it: up, down, another (dormant, lowerlayerdown...) or none #}{% if link == "up" %}{% trans "Link up" %}{% elif link == "down" %}{% trans "Link down" %}{% elif link %}{% blocktrans %}Link {{ link }}{% endblocktrans %}{% else %}{% trans "Link unknown" %}{% endif %} +{% load i18n %}{# a link state as libvirt reports it: up, down, another (dormant, lowerlayerdown...) or none #}{% if link == "up" %}{% trans "Link up" %}{% elif link == "down" %}{% trans "Link down" %}{% elif link and link != "unknown" %}{% blocktrans %}Link {{ link }}{% endblocktrans %}{% else %}{% trans "Link unknown" %}{% endif %} diff --git a/interfaces/tests/test_views.py b/interfaces/tests/test_views.py index 308d9fb3..9d4822ee 100644 --- a/interfaces/tests/test_views.py +++ b/interfaces/tests/test_views.py @@ -157,3 +157,12 @@ class UnchangeableHostTestCase(TestCase): self.assertEqual(response.status_code, 200) for method in (conn.start_iface, conn.stop_iface, conn.delete_iface): method.assert_not_called() + + +class LinkBadgeTestCase(TestCase): + def test_a_link_state_libvirt_calls_unknown_is_said_in_words(self): + from django.template.loader import render_to_string + + for link in ("unknown", None): + self.assertIn("Link unknown", render_to_string("link_badge.html", {"link": link})) + self.assertIn("Link dormant", render_to_string("link_badge.html", {"link": "dormant"}))