Exemple #1
0
    def testParse(self):
        filt = filters.ObjectFilter()

        cfg = rdfvalue.Config(test="ok")
        results = list(filt.Parse(cfg, "test is 'ok'"))
        self.assertEqual([cfg], results)

        cfg = rdfvalue.Config(test="miss")
        results = list(filt.Parse(cfg, "test is 'ok'"))
        self.assertEqual([], results)
Exemple #2
0
    def testParse(self):
        filt = filters.ObjectFilter()

        hit1 = rdf_protodict.AttributedDict(test="hit1")
        hit2 = rdf_protodict.AttributedDict(test="hit2")
        miss = rdf_protodict.AttributedDict(test="miss")
        objs = [hit1, hit2, miss]
        results = filt.Parse(objs, "test is 'hit1'")
        self.assertItemsEqual([hit1], results)
        results = filt.Parse(objs, "test is 'hit2'")
        self.assertItemsEqual([hit2], results)
        results = filt.Parse(objs, "test inset 'hit1,hit2'")
        self.assertItemsEqual([hit1, hit2], results)
Exemple #3
0
    def testParse(self):
        filt = filters.ObjectFilter()

        hit1 = rdfvalue.Config(test="hit1")
        hit2 = rdfvalue.Config(test="hit2")
        miss = rdfvalue.Config(test="miss")
        objs = [hit1, hit2, miss]
        results = filt.Parse(objs, "test is 'hit1'")
        self.assertItemsEqual([hit1], results)
        results = filt.Parse(objs, "test is 'hit2'")
        self.assertItemsEqual([hit2], results)
        results = filt.Parse(objs, "test inset 'hit1,hit2'")
        self.assertItemsEqual([hit1, hit2], results)
Exemple #4
0
 def testValidate(self):
     filt = filters.ObjectFilter()
     self.assertRaises(filters.DefinitionError, filt.Validate, "bad term")
     self.assertFalse(filt.Validate("test is 'ok'"))