From: Oleg Broytman Date: Wed, 25 May 2016 18:50:52 +0000 (+0300) Subject: Add test for searching books by authors X-Git-Tag: 0.0.8~9 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=11790ed879e9546ce1044972036196213008a575;p=m_librarian.git Add test for searching books by authors --- diff --git a/tests/test_search.py b/tests/test_search.py index 1cb55b6..bc6ceca 100755 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -3,7 +3,9 @@ from tests import TestCase, main -from m_librarian.search import search_authors +from m_librarian.db import Author, Book +from m_librarian.search import mk_search_conditions, \ + search_authors, search_books class TestSearch(TestCase): @@ -19,6 +21,16 @@ class TestSearch(TestCase): search_authors('substring', False, {'surname': u'друг'}).count(), 3) + join_expressions = [] + join_expressions.append(Book.j.authors) + conditions = mk_search_conditions( + Author, 'start', False, {'surname': u'друг'}) + join_expressions.extend(conditions) + self.assertEqual( + search_books('start', False, + {'title': u'тест'}, join_expressions).count(), + 2) + if __name__ == "__main__": main()