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"}))