def testPlainTerm(self): """ Test that a regular boring search query with nothing special is parsed as such. """ self.assertEquals(search.parseSearchTerm(u"foo"), (u"foo", None)) self.assertEquals(search.parseSearchTerm(u"foo bar"), (u"foo bar", None))
def testKeywordTerm(self): """ Test keywords in a search query are found and returned. """ self.assertEquals(search.parseSearchTerm(u"foo:bar"), (u"", { u"foo": u"bar" })) self.assertEquals(search.parseSearchTerm(u"foo bar:baz"), (u"foo", { u"bar": u"baz" })) self.assertEquals(search.parseSearchTerm(u"foo bar baz:quux"), (u"foo bar", { u"baz": u"quux" })) self.assertEquals(search.parseSearchTerm(u"foo bar:baz quux"), (u"foo quux", { u"bar": u"baz" })) self.assertEquals( search.parseSearchTerm(u"foo bar:baz quux foobar:barbaz"), (u"foo quux", { u"bar": u"baz", u"foobar": u"barbaz" }))
def testBadlyFormedKeywordTerm(self): """ Test that a keyword search that isn't quite right gets cleaned up. """ self.assertEquals(search.parseSearchTerm(u"foo:"), (u"foo", None)) self.assertEquals(search.parseSearchTerm(u":foo"), (u"foo", None)) self.assertEquals(search.parseSearchTerm(u":"), (u"", None))
def testBadlyFormedKeywordTerm(self): """ Test that a keyword search that isn't quite right gets cleaned up. """ self.assertEquals( search.parseSearchTerm(u"foo:"), (u"foo", None)) self.assertEquals( search.parseSearchTerm(u":foo"), (u"foo", None)) self.assertEquals( search.parseSearchTerm(u":"), (u"", None))
def testKeywordTerm(self): """ Test keywords in a search query are found and returned. """ self.assertEquals( search.parseSearchTerm(u"foo:bar"), (u"", {u"foo": u"bar"})) self.assertEquals( search.parseSearchTerm(u"foo bar:baz"), (u"foo", {u"bar": u"baz"})) self.assertEquals( search.parseSearchTerm(u"foo bar baz:quux"), (u"foo bar", {u"baz": u"quux"})) self.assertEquals( search.parseSearchTerm(u"foo bar:baz quux"), (u"foo quux", {u"bar": u"baz"})) self.assertEquals( search.parseSearchTerm(u"foo bar:baz quux foobar:barbaz"), (u"foo quux", {u"bar": u"baz", u"foobar": u"barbaz"}))