X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=tests%2Ftest_search.py;h=dfea04113ce21656bb4e4842b38663fef588bdca;hb=6714c899a8a8bd5b2c1c707fa1ed22b265e1e1d7;hp=bc6cecabe520a640d2c4b7df30ab6bdd7c8b6d5f;hpb=11790ed879e9546ce1044972036196213008a575;p=m_librarian.git diff --git a/tests/test_search.py b/tests/test_search.py old mode 100755 new mode 100644 index bc6ceca..dfea041 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1,36 +1,24 @@ -#! /usr/bin/env python # coding: utf-8 - -from tests import TestCase, main +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) - - 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) - +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 -if __name__ == "__main__": - main() + 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