Browse Source

Add return value to move_up-down methods

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
3d59782aaf
2 changed files with 10 additions and 4 deletions
  1. 8
      tests/test_dlist.py
  2. 6
      youtube_dl_gui/downloadmanager.py

8
tests/test_dlist.py

@ -118,11 +118,11 @@ class TestMoveUp(unittest.TestCase):
self.dlist = DownloadList(mocks)
def test_move_up(self):
self.dlist.move_up(1)
self.assertTrue(self.dlist.move_up(1))
self.assertEqual(self.dlist._items_list, [1, 0, 2])
def test_move_up_already_on_top(self):
self.dlist.move_up(0)
self.assertFalse(self.dlist.move_up(0))
self.assertEqual(self.dlist._items_list, [0, 1, 2])
def test_move_up_not_exist(self):
@ -138,11 +138,11 @@ class TestMoveDown(unittest.TestCase):
self.dlist = DownloadList(mocks)
def test_move_down(self):
self.dlist.move_down(1)
self.assertTrue(self.dlist.move_down(1))
self.assertEqual(self.dlist._items_list, [0, 2, 1])
def test_move_down_already_on_bottom(self):
self.dlist.move_down(2)
self.assertFalse(self.dlist.move_down(2))
self.assertEqual(self.dlist._items_list, [0, 1, 2])
def test_move_down_not_exist(self):

6
youtube_dl_gui/downloadmanager.py

@ -235,6 +235,9 @@ class DownloadList(object):
if index > 0:
self._swap(index, index - 1)
return True
return False
@synchronized(_SYNC_LOCK)
def move_down(self, object_id):
@ -243,6 +246,9 @@ class DownloadList(object):
if index < (len(self._items_list) - 1):
self._swap(index, index + 1)
return True
return False
@synchronized(_SYNC_LOCK)
def get_item(self, object_id):

Loading…
Cancel
Save