From 11790ed879e9546ce1044972036196213008a575 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 25 May 2016 21:50:52 +0300 Subject: [PATCH] Add test for searching books by authors --- tests/test_search.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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() -- 2.39.5