]> git.phdru.name Git - m_librarian.git/commitdiff
Add test for searching books by authors
authorOleg Broytman <phd@phdru.name>
Wed, 25 May 2016 18:50:52 +0000 (21:50 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 25 May 2016 18:50:52 +0000 (21:50 +0300)
tests/test_search.py

index 1cb55b61d306bf12d18a9427e0c00dd15d3f6fb8..bc6cecabe520a640d2c4b7df30ab6bdd7c8b6d5f 100755 (executable)
@@ -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()