def perform_short_q(self): short_q = BaseSimpleBookFinder(query='42') with self.assertRaises(search_errors.TooShortQuery) as e: short_q.check_query() exception_ = e.exception return short_q, exception_
def test_query_split(self): fixtures = [ ('some', ['some'], None), ('apple orange', ['apple', 'orange'], 'words should be splited'), ('абвг\nabcd', ['абвг', 'abcd'], 'new line should be ignored and process as space'), ] for query, expected, mes in fixtures: finder = BaseSimpleBookFinder(query=query) actual = finder.get_query_words() self.assertEqual(expected, actual, mes)
def test_empty_query(self): empty_q = BaseSimpleBookFinder() with self.assertRaises(search_errors.NoQuery): empty_q.check_query() empty_q2 = BaseSimpleBookFinder(query='') with self.assertRaises(search_errors.NoQuery): empty_q2.check_query()