[Tests] fix/enable most ui tests on Windows

Closes: https://github.com/deluge-torrent/deluge/pull/348
This commit is contained in:
Chase Sterling 2022-01-26 12:45:33 -05:00 committed by Calum Lind
parent 932c3c123f
commit d8acadb085
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
1 changed files with 20 additions and 30 deletions

View File

@ -92,10 +92,6 @@ class UIWithDaemonBaseTestCase(UIBaseTestCase, DaemonBase):
class DelugeEntryTestCase(BaseTestCase): class DelugeEntryTestCase(BaseTestCase):
if windows_check():
skip = 'Console ui test on Windows broken due to sys args issue'
def set_up(self): def set_up(self):
common.set_tmp_config_dir() common.set_tmp_config_dir()
return component.start() return component.start()
@ -157,6 +153,11 @@ class DelugeEntryTestCase(BaseTestCase):
class GtkUIBaseTestCase(UIBaseTestCase): class GtkUIBaseTestCase(UIBaseTestCase):
"""Implement all GtkUI tests here""" """Implement all GtkUI tests here"""
if windows_check():
skip = (
'Gtk tests on Windows have some issue with the mutex already being created'
)
def test_start_gtk3ui(self): def test_start_gtk3ui(self):
self.patch(sys, 'argv', self.var['sys_arg_cmd']) self.patch(sys, 'argv', self.var['sys_arg_cmd'])
@ -240,16 +241,14 @@ class WebUIBaseTestCase(UIBaseTestCase):
class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase): class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
if windows_check():
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname): def __init__(self, testname):
super().__init__(testname) super().__init__(testname)
WebUIBaseTestCase.__init__(self) WebUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge-web' self.var['cmd_name'] = 'deluge-web'
self.var['start_cmd'] = deluge.ui.web.start self.var['start_cmd'] = deluge.ui.web.start
self.var['sys_arg_cmd'] = ['./deluge-web', '--do-not-daemonize'] self.var['sys_arg_cmd'] = ['./deluge-web']
if not windows_check():
self.var['sys_arg_cmd'].append('--do-not-daemonize')
def set_up(self): def set_up(self):
return WebUIBaseTestCase.set_up(self) return WebUIBaseTestCase.set_up(self)
@ -259,16 +258,14 @@ class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase): class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase):
if windows_check():
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname): def __init__(self, testname):
super().__init__(testname) super().__init__(testname)
WebUIBaseTestCase.__init__(self) WebUIBaseTestCase.__init__(self)
self.var['cmd_name'] = 'deluge web' self.var['cmd_name'] = 'deluge web'
self.var['start_cmd'] = ui_entry.start_ui self.var['start_cmd'] = ui_entry.start_ui
self.var['sys_arg_cmd'] = ['./deluge', 'web', '--do-not-daemonize'] self.var['sys_arg_cmd'] = ['./deluge', 'web']
if not windows_check():
self.var['sys_arg_cmd'].append('--do-not-daemonize')
def set_up(self): def set_up(self):
return WebUIBaseTestCase.set_up(self) return WebUIBaseTestCase.set_up(self)
@ -387,7 +384,7 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_console_command_add(self): def test_console_command_add(self):
filename = common.get_test_data_file('test.torrent') filename = common.get_test_data_file('test.torrent')
self.patch_arg_command(['add ' + filename]) self.patch_arg_command([f'add "{filename}"'])
fd = StringFileDescriptor(sys.stdout) fd = StringFileDescriptor(sys.stdout)
self.patch(sys, 'stdout', fd) self.patch(sys, 'stdout', fd)
@ -401,9 +398,10 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_console_command_add_move_completed(self): def test_console_command_add_move_completed(self):
filename = common.get_test_data_file('test.torrent') filename = common.get_test_data_file('test.torrent')
tmp_path = 'c:\\tmp' if windows_check() else '/tmp'
self.patch_arg_command( self.patch_arg_command(
[ [
'add --move-path /tmp ' + filename + ' ; status' f'add --move-path "{tmp_path}" "{filename}" ; status'
' ; manage' ' ; manage'
' ab570cdd5a17ea1b61e970bb72047de141bce173' ' ab570cdd5a17ea1b61e970bb72047de141bce173'
' move_completed' ' move_completed'
@ -417,8 +415,12 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
std_output = fd.out.getvalue() std_output = fd.out.getvalue()
self.assertTrue( self.assertTrue(
std_output.endswith('move_completed: True\nmove_completed_path: /tmp\n') std_output.endswith(
or std_output.endswith('move_completed_path: /tmp\nmove_completed: True\n') f'move_completed: True\nmove_completed_path: {tmp_path}\n'
)
or std_output.endswith(
f'move_completed_path: {tmp_path}\nmove_completed: True\n'
)
) )
@defer.inlineCallbacks @defer.inlineCallbacks
@ -452,10 +454,6 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
class ConsoleScriptEntryWithDaemonTestCase( class ConsoleScriptEntryWithDaemonTestCase(
BaseTestCase, ConsoleUIWithDaemonBaseTestCase BaseTestCase, ConsoleUIWithDaemonBaseTestCase
): ):
if windows_check():
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname): def __init__(self, testname):
super().__init__(testname) super().__init__(testname)
ConsoleUIWithDaemonBaseTestCase.__init__(self) ConsoleUIWithDaemonBaseTestCase.__init__(self)
@ -478,10 +476,6 @@ class ConsoleScriptEntryWithDaemonTestCase(
class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase): class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
if windows_check():
skip = 'Console ui test on Windows broken due to sys args issue'
def __init__(self, testname): def __init__(self, testname):
super().__init__(testname) super().__init__(testname)
ConsoleUIBaseTestCase.__init__(self) ConsoleUIBaseTestCase.__init__(self)
@ -497,10 +491,6 @@ class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase): class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase):
if windows_check():
skip = 'cannot test console ui on windows'
def __init__(self, testname): def __init__(self, testname):
super().__init__(testname) super().__init__(testname)
ConsoleUIBaseTestCase.__init__(self) ConsoleUIBaseTestCase.__init__(self)