Пример #1
0
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
Пример #2
0
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
Пример #3
0
def test_select_shouldShowLoadingWhileGettingItemsAsynchronously():
    asyncFolder = mocks.NeverLoadingFolder("Dynamic", [])
    dynamicMainFolder = mocks.Folder("Main", [asyncFolder])
    menu = Menu(dynamicMainFolder)
    menu.select()
    assert asyncFolder.loadItemsCnt == 0
    assert menu.item() is menu._loadingItem
Пример #4
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
Пример #5
0
def test_moveBy3_withBackItem():
    menu = Menu(mainFolder)
    menu.moveBy(3)
    assert menu.item() is menu._backItem
Пример #6
0
def test_moveBy1_withBackItem():
    menu = Menu(mainFolder)
    menu.moveBy(1)
    assert menu.item() is folder2
Пример #7
0
def test_moveBy0_withBackItem_shouldDoNothing():
    menu = Menu(mainFolder)
    menu.moveBy(0)
    assert menu.item() is folder1
Пример #8
0
def test_moveByMinus1_withoutBackItem():
    menu = Menu(mainFolder, showBackItem=False)
    menu.moveBy(-1)
    assert menu.item() is folder3
Пример #9
0
def test_moveBy_overflow_withoutBackItem():
    menu = Menu(mainFolder, showBackItem=False)
    menu.moveBy(4)
    assert menu.item() is folder2
Пример #10
0
def test_moveBy2():
    menu = Menu(mainFolder, showBackItem=False)
    menu.moveBy(2)
    assert menu.item() is folder3
Пример #11
0
def test_updateItemsForFolder_shouldDoNothingForDifferentFolder():
    menu = Menu(mainFolder)
    menu._updateItemsForFolder(folder2, folder2.items(), 0, False)
    assert menu.folder() is mainFolder
    assert menu.item() is folder1
Пример #12
0
def test_select_shouldOpenFolderAndShowItsFirstEntry():
    menu = Menu(mainFolder)
    menu.moveBy(1)
    menu.select()
    assert menu.folder() is folder2
    assert menu.item() is folder2a
Пример #13
0
def test_moveByMinus2_withBackItem():
    menu = Menu(mainFolder)
    menu.moveBy(-2)
    assert menu.item() is folder3
Пример #14
0
def test_moveBy_overflow_withBackItem():
    menu = Menu(mainFolder)
    menu.moveBy(4)
    assert menu.item() is folder1
Пример #15
0
def test_moveBy0_shouldDoNothing():
    menu = Menu(mainFolder, showBackItem=False)
    menu.moveBy(0)
    assert menu.item() is folder1
Пример #16
0
def test_init():
    menu = Menu(mainFolder)
    assert menu.folder() is mainFolder
    assert menu.item() is folder1
    assert menu.isRoot() is True
Пример #17
0
def test_back_shouldRememberIndex():
    menu = Menu(mainFolder)
    menu.moveBy(1)
    menu.select()
    menu.back()
    assert menu.item() is folder2
Пример #18
0
def test_withBackItem_shouldShowBackItemInEmptyFolder():
    menu = Menu(emptyFolder)
    assert menu.item() is menu._backItem
Пример #19
0
def test_select_emptyFolder_shouldDoNothing():
    menu = Menu(emptyFolder, showBackItem=False)
    assert menu.item() is menu._emptyItem
    menu.select()
    assert menu.item() is menu._emptyItem
Пример #20
0
def test_moveByMinus1_withBackItem():
    menu = Menu(mainFolder)
    menu.moveBy(-1)
    assert menu.item() is menu._backItem
Пример #21
0
def test_select_shouldShowRetryActionWhenLoadingFolderFailed_Asynchronously():
    asyncFolder = mocks.FailingSynchronAsyncFolder("Dynamic", Exception(""))
    dynamicMainFolder = mocks.Folder("Main", [asyncFolder])
    menu = Menu(dynamicMainFolder)
    menu.select()
    assert isinstance(menu.item(), _RetryAction)
Пример #22
0
def test_moveBy1_shouldNotFailForEmptyFolder():
    menu = Menu(emptyFolder, showBackItem=False)
    menu.moveBy(1)
    assert menu.item() is menu._emptyItem
Пример #23
0
def test_moveByMinus1_withBackItem_shouldNotFailForEmptyFolder():
    menu = Menu(emptyFolder)
    menu.moveBy(-1)
    assert menu.item() is menu._backItem