From 032a651efaa5374d8a3d6f6af8c04806f2022106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thayn=C3=A3=20Moretti?= Date: Tue, 1 Sep 2020 22:12:54 -0300 Subject: [PATCH] Improve network traffic module tests --- bumblebee_status/modules/contrib/network_traffic.py | 3 --- tests/modules/contrib/test_network_traffic.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bumblebee_status/modules/contrib/network_traffic.py b/bumblebee_status/modules/contrib/network_traffic.py index f9c8c98..ad5781f 100644 --- a/bumblebee_status/modules/contrib/network_traffic.py +++ b/bumblebee_status/modules/contrib/network_traffic.py @@ -97,9 +97,6 @@ class BandwidthInfo(object): """Return default active network adapter""" gateway = netifaces.gateways()["default"] - if not gateway: - raise "No default gateway found" - return gateway[netifaces.AF_INET][1] @classmethod diff --git a/tests/modules/contrib/test_network_traffic.py b/tests/modules/contrib/test_network_traffic.py index 1abae72..c18692e 100644 --- a/tests/modules/contrib/test_network_traffic.py +++ b/tests/modules/contrib/test_network_traffic.py @@ -89,3 +89,15 @@ class TestNetworkTrafficUnit(TestCase): assert download_widget(module).full_text() == '30.00MiB/s' assert upload_widget(module).full_text() == '512.00KiB/s' + + def test_widget_states(self): + module = build_module() + + assert module.state(download_widget(module)) == 'rx' + assert module.state(upload_widget(module)) == 'tx' + + def test_invalid_widget_state(self): + module = build_module() + invalid_widget = core.widget.Widget(name='invalid') + + assert module.state(invalid_widget) == None