def test_parse_combined(): searchquery = u"((fulltext=münchen) OR (title=münchen)) AND ((NOT (full=Strauß)) OR (year > 2000))" st = parser.parse_string(searchquery) left = Or(FulltextMatch(u"münchen"), AttributeMatch(u"title", u"münchen")) right = Or(Not(FullMatch(u"Strauß")), AttributeCompare(u"year", ">", u"2000")) assert isinstance(st, And) assert st.left == left assert st.right == right
def test_parse_not(): st = parser.parse_string(u'not(full=torpedo)') assert st == Not(FullMatch(u"torpedo"))
def test_parse_plain_and(): st = parser.parse_string(u'full=haus and full=ofit') assert st == And(FullMatch(u"haus"), FullMatch(u"ofit"))
def test_parse_plain_or(): st = parser.parse_string(u'full=haus or full=ofit') assert st == Or(FullMatch(u"haus"), FullMatch(u"ofit"))
def test_parse_full_unicode_quoted(): text = u'"Öffentliche schöne Häuser in München"' st = parser.parse_string(u'full=' + text) assert st == FullMatch(text.strip('"'))
def test_parse_simple_query(simple_query): searchquery, expected = simple_query st = parser.parse_string(searchquery) assert st == expected
def test_parse_unicode(): text = u"πλανήτης\uEEEE" st = parser.parse_string(u"full=" + text) assert st == FullMatch(text)