def test_and_queries_match_after_sorting(self): null = NullQuery() any = AnyQuery() term = TermQuery("foo") field = FieldQuery("x", "y") first = AndQuery(null, any, term, field) second = AndQuery(any, null, field, term) self.assertEqual(first, second)
def test_match_if_query_is_anywhere_in_string(self): q = TermQuery('bar') self.assertTrue(q.match('foo bar baz'))
def test_failes_if_all_subterms_fail(self): q1 = TermQuery("a") q2 = TermQuery("b") q = OrQuery(q1, q2) self.assertFalse(q.match("cd"))
def test_failes_if_at_least_one_subterm_fails(self): q1 = TermQuery("a") q2 = TermQuery("b") q = AndQuery(q1, q2) self.assertFalse(q.match("ac"))
def test_matches_if_at_least_one_subterm_matchs(self): q1 = TermQuery("a") q2 = TermQuery("b") q = OrQuery(q1, q2) self.assertTrue(q.match("ac"))
def test_spaces_in_query_are_not_stripped(self): q = TermQuery('foo bar') self.assertFalse(q.match('foobar'))
def test_matches_if_all_subterms_match(self): q1 = TermQuery("a") q2 = TermQuery("b") q = AndQuery(q1, q2) self.assertTrue(q.match("ab"))
def test_spaces_in_search_subject_are_not_stripped(self): q = TermQuery('oob') self.assertFalse(q.match('foo bar baz'))
def test_bad_field_name_returns_term_query(self): string = "foo:bar" actual = parse(string) expected = TermQuery(string) self.assertEqual(actual, expected)
def test_parsing_simple_terms(self): string = "foo bar" expected = TermQuery(string) actual = parse(string) self.assertEqual(actual, expected)
def test_match_arguments_are_case_insensitive(self): q = TermQuery('bar') self.assertTrue(q.match('FOO BAR BAZ'))
def test_query_terms_are_case_insensitive(self): q = TermQuery('BAR') self.assertTrue(q.match('foo bar baz'))