Example #1
0
 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))
Example #2
0
 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"
         }))
Example #3
0
 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))
Example #4
0
    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))
Example #5
0
    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))
Example #6
0
 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"}))