Source

pida-hacks / pida-plugins / library / test_library.py

Full commit
# -*- coding: utf-8 -*- 

# Copyright (c) 2012 The PIDA Project

from mock import Mock
from .library import LibraryView
from pygtkhelpers.utils import refresh_gui

def pytest_funcarg__boss(request):
    return Mock(name='boss')


def test_view(boss):
    view = LibraryView(boss.svc)
    view.fetch_books()
    refresh_gui(delay=.5)
    books = list(view.books_list)
    pygtk = next(x for x in books if x.name == 'pygtk')
    view.books_list.selected_item = pygtk
    refresh_gui()
    view.books_list.emit('item-activated', pygtk)
    refresh_gui(delay=.5)
    content_item = view.contents_tree[0]
    view.contents_tree.emit('item-activated', content_item)
    refresh_gui()
    Mock.assert_called_with(boss.svc.browse_file, 'file://' + content_item.path)



# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: