Merge pull request #701 from izn/improve-network-traffic-tests

Improve network traffic module tests
This commit is contained in:
tobi-wan-kenobi 2020-09-02 07:14:53 +02:00 committed by GitHub
commit 7b57299cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -97,9 +97,6 @@ class BandwidthInfo(object):
"""Return default active network adapter""" """Return default active network adapter"""
gateway = netifaces.gateways()["default"] gateway = netifaces.gateways()["default"]
if not gateway:
raise "No default gateway found"
return gateway[netifaces.AF_INET][1] return gateway[netifaces.AF_INET][1]
@classmethod @classmethod

View file

@ -89,3 +89,15 @@ class TestNetworkTrafficUnit(TestCase):
assert download_widget(module).full_text() == '30.00MiB/s' assert download_widget(module).full_text() == '30.00MiB/s'
assert upload_widget(module).full_text() == '512.00KiB/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