-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gtkview.py
More file actions
36 lines (28 loc) · 1.18 KB
/
test_gtkview.py
File metadata and controls
36 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pytest
from utils import parse_title
from store.sqlite import SqliteStore, ReadError
from view.gtk import Handler
from gi.repository import Gtk
from uuid import uuid4
@pytest.fixture
def build_window():
"""Surrogate for main(), builds window from glade files
without showing them/ starting Gtk.main()
"""
db = SqliteStore(':memory:')
builder = Gtk.Builder()
builder.add_from_file("view/notebook.glade")
notes = ['0 Test Note', '1 Test Note', '2 Test Note', '3 Test Note']
# Glade does not accept python types for Liststore, so we have to build
# the model in python
liststore = Gtk.ListStore(str, str) # Title and uuid
for n in notes:
db.add_note(n)
view = builder.get_object("treeview_notelist")
view.set_model(liststore)
selection = builder.get_object("treeview_notelist_selection")
selection.select_iter(liststore.get_iter("0")) # 0 means first note, no search in-tree
textbuffer = builder.get_object("current_note_buffer")
handler = Handler(liststore, liststore.get_iter("0"), db)
builder.connect_signals(handler)
return builder, handler, liststore, selection, textbuffer, db