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)
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)
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)
def testValidate(self): filt = filters.ObjectFilter() self.assertRaises(filters.DefinitionError, filt.Validate, "bad term") self.assertFalse(filt.Validate("test is 'ok'"))