X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=tests%2Ftest_search.py;h=dfea04113ce21656bb4e4842b38663fef588bdca;hb=6b291135cca79646a47544dec8584f96944ed3de;hp=7fdf9fe136f2e51af3dab30dc5ab8dc41dbb42cf;hpb=e19edc2c673b2f672d613c97bce91c0ec238e80a;p=m_librarian.git diff --git a/tests/test_search.py b/tests/test_search.py index 7fdf9fe..dfea041 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1,30 +1,24 @@ # coding: utf-8 -from tests import TestCase +from dbutils import setup_module, teardown_module # noqa +from dbutils import load_inpx from m_librarian.db import Author, Book from m_librarian.search import mk_search_conditions, \ search_authors, search_books -class TestSearch(TestCase): - def test_search_authors(self): - self.import_inpx('test.inpx') - self.assertEqual( - search_authors('full', True, {'surname': u'Друг'}).count(), 1) - self.assertEqual( - search_authors('start', True, {'surname': u'Друг'}).count(), 2) - self.assertEqual( - search_authors('substring', True, {'surname': u'Друг'}).count(), 2) - self.assertEqual( - search_authors('substring', False, {'surname': u'друг'}).count(), - 3) +def test_search_authors(): + load_inpx('test.inpx') + assert search_authors('full', True, {'surname': u'Друг'}).count() == 1 + assert search_authors('start', True, {'surname': u'Друг'}).count() == 2 + assert search_authors('substring', True, {'surname': u'Друг'}).count() == 2 + assert 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) + join_expressions = [] + join_expressions.append(Book.j.authors) + conditions = mk_search_conditions( + Author, 'start', False, {'surname': u'друг'}) + join_expressions.extend(conditions) + assert search_books( + 'start', False, {'title': u'тест'}, join_expressions).count() == 2