def test_albums_sort(settings): gal = Gallery(settings, ncpu=1) album = REF['dir1'] subdirs = list(album['subdirs']) settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('') assert [alb.name for alb in a.albums] == subdirs settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('') assert [alb.name for alb in a.albums] == list(reversed(subdirs)) titles = [im.title for im in a.albums] titles.sort() settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('title') assert [im.title for im in a.albums] == titles settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('title') assert [im.title for im in a.albums] == list(reversed(titles))
def test_albums_sort(settings): gal = Gallery(settings, ncpu=1) album = REF['dir1'] subdirs = list(album['subdirs']) settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('') assert [alb.name for alb in a.albums] == subdirs settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('') assert [alb.name for alb in a.albums] == list(reversed(subdirs)) titles = [im.title for im in a.albums] titles.sort() settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('title') assert [im.title for im in a.albums] == titles settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('title') assert [im.title for im in a.albums] == list(reversed(titles)) orders = ['01', '02', '03'] orders.sort() settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('meta.order') assert [d.meta['order'][0] for d in a.albums] == orders settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs('meta.order') assert [d.meta['order'][0] for d in a.albums] == list(reversed(orders)) settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs(['meta.partialorder', 'meta.order']) assert [d.name for d in a.albums] == list(['test1', 'test2', 'test3']) settings['albums_sort_reverse'] = False a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs(['meta.partialorderb', 'name']) assert [d.name for d in a.albums] == list(['test2', 'test3', 'test1']) settings['albums_sort_reverse'] = True a = Album('dir1', settings, album['subdirs'], album['medias'], gal) a.sort_subdirs(['meta.partialorderb', 'name']) assert [d.name for d in a.albums] == list(['test1', 'test3', 'test2'])