Source

pida-hacks / pida-plugins / bookmark / test_bookmark.py

Full commit
# -*- coding: utf-8 -*- 
import gtk
from pygtkhelpers.utils import refresh_gui
from .bookmark import BookmarkView, Bookmark, BookmarkItemFile
from pida.core.projects import Project
import mock

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

def test_view(tmpdir, boss):
    Project.create_blank_project_file('test', str(tmpdir))
    project = Project(str(tmpdir))

    boss.cmd.return_value = project

    s = Bookmark(boss)
    s.create_all()
    view = BookmarkView(s)
    s._view = view

    s.load()

    myfile = BookmarkItemFile(s, __file__)
    s.add_item(myfile)
    s.add_item(myfile)
    w = gtk.Window()
    w.add(view.widget)
    w.show_all()
    refresh_gui()
    myfile._do_set_line(3)
    assert myfile.line == 3
    refresh_gui()
    s.save()

    s.list_files().selected_item = myfile
    assert s._current is myfile

    boss.cmd.reset_mock()
    view._on_item_activated(s.list_files, myfile)
    assert boss.cmd.called_with('buffer', 'open_file',
                                filename='/home/ronny/Projects/pissoff/pida/pida-plugins/bookmark/test_bookmark.py',
                                line=3)


    print tmpdir.join('.pida-metadata/bookmark/bookmark.json').read()




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