-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtests.py
36 lines (27 loc) · 875 Bytes
/
tests.py
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
from collections import defaultdict
from unittest import TestCase, main
import gi
gi.require_version('Gtk', '3.0')
from instantsearch import SearchController, _MenuItem
cached_titles = [
'Journal',
'Journal:2021',
'Journal:2021:12',
'Journal:foo',
'Journal:foo:bar',
'Journal:foo:bar:fourth',
'test',
'Journal:test',
'foo test',
'foo (test)'
]
class TestSearch(TestCase):
def _search(self, query, expected):
menu = defaultdict(_MenuItem)
SearchController.header_search(query, menu, cached_titles)
self.assertListEqual(expected, [*menu])
def test_header(self):
self._search("foo", ['Journal:foo', 'Journal:foo:bar', 'Journal:foo:bar:fourth', 'foo test', 'foo (test)'])
self._search("tes", ['test', 'Journal:test', 'foo test', 'foo (test)'])
if __name__ == '__main__':
main()