1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 05:48:03 +01:00

in mock we trust

This commit is contained in:
Guido Serra
2019-08-30 16:25:12 +02:00
parent 94bf1ab01e
commit 3035004c6d

View File

@@ -1,4 +1,5 @@
import unittest import unittest
from unittest import mock
from wicd import wnettools from wicd import wnettools
class TestWnettools(unittest.TestCase): class TestWnettools(unittest.TestCase):
@@ -11,9 +12,13 @@ class TestWnettools(unittest.TestCase):
#self.assertTrue('wlan0' in interfaces) #self.assertTrue('wlan0' in interfaces)
self.assertTrue(type(interfaces) == list) self.assertTrue(type(interfaces) == list)
def test_find_wired_interface(self): @mock.patch('wicd.wnettools.os')
@mock.patch('wicd.wnettools.open')
def test_find_wired_interface(self, mock_f, mock_os):
mock_os.listdir.return_value = ['eth0']
mock_os.path.isdir.return_value = True
mock_f.return_value.readlines.return_value = "1"
interfaces = wnettools.GetWiredInterfaces() interfaces = wnettools.GetWiredInterfaces()
# eth0 may change depending on your system
self.assertTrue('eth0' in interfaces) self.assertTrue('eth0' in interfaces)
def test_wext_is_valid_wpasupplicant_driver(self): def test_wext_is_valid_wpasupplicant_driver(self):