]> git.phdru.name Git - m_librarian.git/blob - tests/test_search.py
Docs: Update TODO
[m_librarian.git] / tests / test_search.py
1 # coding: utf-8
2
3 from dbutils import setup_module, teardown_module  # noqa
4 from dbutils import load_inpx
5 from m_librarian.db import Author, Book
6 from m_librarian.search import mk_search_conditions, \
7     search_authors, search_books
8
9
10 def test_search_authors():
11     load_inpx('test.inpx')
12     assert search_authors('full', True, {'surname': u'Друг'}).count() == 1
13     assert search_authors('start', True, {'surname': u'Друг'}).count() == 2
14     assert search_authors('substring', True, {'surname': u'Друг'}).count() == 2
15     assert search_authors(
16         'substring', False, {'surname': u'друг'}).count() == 3
17
18     join_expressions = []
19     join_expressions.append(Book.j.authors)
20     conditions = mk_search_conditions(
21         Author, 'start', False, {'surname': u'друг'})
22     join_expressions.extend(conditions)
23     assert search_books(
24         'start', False, {'title': u'тест'}, join_expressions).count() == 2