def test_reset_shouldGoToFirstItemOfMainFolder(): menu = Menu(mainFolder) menu.moveBy(1).select().moveBy(1).select() menu.reset() assert menu.folder() is mainFolder assert menu.item() is folder1 assert len(menu._menuStack) == 0
def test_back_shouldGoToLastElementIfParentItemListWasShortended_withBackItem(): subFolders = [Folder("a", []), Folder("b", []), Folder("c", [])] folder = Folder("", subFolders) menu = Menu(folder) menu.moveBy(-1).select() subFolders.pop() menu.back() assert menu.item() is menu._backItem
def test_back_multiLevel(): menu = Menu(mainFolder) menu.moveBy(1).select().moveBy(1).select() menu.back() assert menu.folder() is folder2 assert menu.item() is folder2b menu.back() assert menu.folder() is mainFolder assert menu.item() is folder2
def test_moveBy3_withBackItem(): menu = Menu(mainFolder) menu.moveBy(3) assert menu.item() is menu._backItem
def test_moveBy1_withBackItem(): menu = Menu(mainFolder) menu.moveBy(1) assert menu.item() is folder2
def test_moveBy0_withBackItem_shouldDoNothing(): menu = Menu(mainFolder) menu.moveBy(0) assert menu.item() is folder1
def test_moveDoesNotChangeTheFolder(): menu = Menu(mainFolder) menu.moveBy(1) assert menu.folder() is mainFolder assert menu.isRoot() is True
def test_moveByMinus1_withoutBackItem(): menu = Menu(mainFolder, showBackItem=False) menu.moveBy(-1) assert menu.item() is folder3
def test_select_shouldOpenFolderAndShowItsFirstEntry(): menu = Menu(mainFolder) menu.moveBy(1) menu.select() assert menu.folder() is folder2 assert menu.item() is folder2a
def test_moveByMinus2_withBackItem(): menu = Menu(mainFolder) menu.moveBy(-2) assert menu.item() is folder3
def test_moveBy0_shouldDoNothing(): menu = Menu(mainFolder, showBackItem=False) menu.moveBy(0) assert menu.item() is folder1
def test_back_shouldRememberIndex(): menu = Menu(mainFolder) menu.moveBy(1) menu.select() menu.back() assert menu.item() is folder2
def test_select_multiLevel(): menu = Menu(mainFolder) menu.moveBy(1).select().moveBy(1).select() assert menu.folder() is folder2b
def test_moveBy_overflow_withBackItem(): menu = Menu(mainFolder) menu.moveBy(4) assert menu.item() is folder1
def test_moveBy2(): menu = Menu(mainFolder, showBackItem=False) menu.moveBy(2) assert menu.item() is folder3
def test_moveByMinus1_withBackItem(): menu = Menu(mainFolder) menu.moveBy(-1) assert menu.item() is menu._backItem
def test_moveBy_overflow_withoutBackItem(): menu = Menu(mainFolder, showBackItem=False) menu.moveBy(4) assert menu.item() is folder2
def test_moveBy1_shouldNotFailForEmptyFolder(): menu = Menu(emptyFolder, showBackItem=False) menu.moveBy(1) assert menu.item() is menu._emptyItem
def test_moveByMinus1_withBackItem_shouldNotFailForEmptyFolder(): menu = Menu(emptyFolder) menu.moveBy(-1) assert menu.item() is menu._backItem