class WhooshEmptyFacetErrorWorkaroundTestCase(BaseBloodhoundSearchTest): def setUp(self): super(WhooshEmptyFacetErrorWorkaroundTestCase, self).setUp() self.whoosh_backend = WhooshBackend(self.env) self.whoosh_backend.recreate_index() self.parser = DefaultQueryParser(self.env) self.empty_facet_workaround = WhooshEmptyFacetErrorWorkaround(self.env) def tearDown(self): shutil.rmtree(self.env.path) self.env.reset_db() def test_set_should_not_be_empty_fields(self): self.insert_ticket("test x") result = self.whoosh_backend.query(query.Every()) self.print_result(result) doc = result.docs[0] null_marker = WhooshEmptyFacetErrorWorkaround.NULL_MARKER self.assertEqual(null_marker, doc["component"]) self.assertEqual(null_marker, doc["status"]) self.assertEqual(null_marker, doc["milestone"]) def test_can_fix_query_filter(self): parsed_filter = self.parser.parse_filters( ["type:ticket", "NOT (milestone:*)"]) query_parameters = dict(filter=parsed_filter) self.empty_facet_workaround.query_pre_process( query_parameters) result_filter = query_parameters["filter"] self.assertEquals('(type:ticket AND milestone:empty)', str(result_filter)) def test_does_interfere_query_filter_if_not_needed(self): parsed_filter = self.parser.parse_filters( ["type:ticket", "milestone:aaa"]) query_parameters = dict(filter=parsed_filter) self.empty_facet_workaround.query_pre_process( query_parameters) result_filter = query_parameters["filter"] self.assertEquals('(type:ticket AND milestone:aaa)', str(result_filter))
def setUp(self): super(WhooshEmptyFacetErrorWorkaroundTestCase, self).setUp() self.whoosh_backend = WhooshBackend(self.env) self.whoosh_backend.recreate_index() self.parser = DefaultQueryParser(self.env) self.empty_facet_workaround = WhooshEmptyFacetErrorWorkaround(self.env)