1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 12:28:08 +01:00

Updated Preferences dialog and added test cases for wnettools

This commit is contained in:
Adam Blackburn
2008-12-23 11:39:55 -06:00
parent c737a5d7d2
commit 43d6acfc47
5 changed files with 641 additions and 548 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -220,6 +220,23 @@ class configure(Command):
item_in.close()
shutil.copymode(original_name, final_name)
class test(Command):
description = "run Wicd's unit tests"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print "importing tests"
import tests
print 'running tests'
tests.run_tests()
class get_translations(Command):
description = "download the translations from the online translator"
@@ -330,7 +347,7 @@ try:
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ]))
if not wpath.no_install_pmutils:
data.append(( wpath.pmutils, ['other/55wicd' ]))
print 'Creating pid path', os.path.basename(wpath.pidfile)
print 'Using pid path', os.path.basename(wpath.pidfile)
print 'Language support for',
for language in os.listdir('translations/'):
if not language.startswith('.'):
@@ -354,7 +371,7 @@ iwscan_ext = Extension(name = 'iwscan',
libraries = ['iw'],
sources = ['depends/python-iwscan/pyiwscan.c'])
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall},
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall, 'test' : test},
name="Wicd",
version=VERSION_NUM,
description="A wireless and wired network manager",

9
tests/__init__.py Normal file
View File

@@ -0,0 +1,9 @@
def run_tests():
import unittest
test_suite = unittest.TestSuite()
import testwnettools
test_suite.addTest(testwnettools.suite())
unittest.TextTestRunner(verbosity=5).run(test_suite)

66
tests/testwnettools.py Normal file
View File

@@ -0,0 +1,66 @@
import unittest
from wicd import wnettools
class TestWnettools(unittest.TestCase):
def setUp(self):
self.interface = wnettools.BaseInterface('eth0')
def test_find_wireless_interface(self):
interfaces = wnettools.GetWirelessInterfaces()
# wlan0 may change depending on your system
self.assertTrue('wlan0' in interfaces)
def test_find_wired_interface(self):
interfaces = wnettools.GetWiredInterfaces()
# eth0 may change depending on your system
self.assertTrue('eth0' in interfaces)
def test_wext_is_valid_wpasupplicant_driver(self):
self.assertTrue(wnettools.IsValidWpaSuppDriver('wext'))
def test_needs_external_calls_not_implemented(self):
self.assertRaises(NotImplementedError, wnettools.NeedsExternalCalls)
def test_get_ip_not_implemented(self):
self.assertRaises(NotImplementedError, self.interface.GetIP)
def test_is_up_not_implemented(self):
self.assertRaises(NotImplementedError, self.interface.IsUp)
def test_enable_debug_mode(self):
self.interface.SetDebugMode(True)
self.assertTrue(self.interface.verbose)
def test_disable_debug_mode(self):
self.interface.SetDebugMode(False)
self.assertFalse(self.interface.verbose)
def test_interface_name_sanitation(self):
interface = wnettools.BaseInterface('blahblah; uptime > /tmp/blah | cat')
self.assertEquals(interface.iface, 'blahblahuptimetmpblahcat')
def test_freq_translation_low(self):
freq = '2.412 GHz'
interface = wnettools.BaseWirelessInterface('wlan0')
self.assertEquals(interface._FreqToChannel(freq), 1)
def test_freq_translation_high(self):
freq = '2.484 GHz'
interface = wnettools.BaseWirelessInterface('wlan0')
self.assertEquals(interface._FreqToChannel(freq), 14)
def test_generate_psk(self):
interface = wnettools.BaseWirelessInterface('wlan0')
psk = interface.GeneratePSK({'essid' : 'Network 1', 'key' : 'arandompassphrase'})
self.assertEquals(psk, 'd70463014514f4b4ebb8e3aebbdec13f4437ac3a9af084b3433f3710e658a7be')
def suite():
suite = unittest.TestSuite()
tests = []
[ tests.append(test) for test in dir(TestWnettools) if test.startswith('test') ]
for test in tests:
suite.addTest(TestWnettools(test))
return suite
if __name__ == '__main__':
unittest.main()

View File

@@ -364,7 +364,8 @@ class TrayIcon(object):
if DBUS_AVAIL:
self.toggle_wicd_gui()
else:
gui.error(None, language["daemon_unavailable"])
# gui.error(None, language["daemon_unavailable"])
pass
def on_quit(self, widget=None):
""" Closes the tray icon. """