Exemplo n.º 1
0
	def test_event_attribute(self):
		g = event.EventGenerator()
		events = g.randomEvents(100)
		for i in range(15):
			events[i].setAttribute("foo", "bar")
		attr_foo_is_bar = rulecomponents.event_attribute("foo", lambda **kwargs: "bar", "eq")
		self.assert_(len(attr_foo_is_bar(query_events=events))==15)
		for i in range(10, 20):
			events[i].setAttribute("foo", str(i))
		attr_foo_is_ge15 = rulecomponents.event_attribute("foo", lambda **kwargs: "15", "ge")
		attr_foo_is_le10 = rulecomponents.event_attribute("foo", lambda **kwargs: "10", "le")
		self.assert_(len(attr_foo_is_ge15(query_events=events))==5)
		self.assert_(attr_foo_is_le10(query_events=events)[0] == events[10])
Exemplo n.º 2
0
 def test_event_attribute(self):
     g = event.EventGenerator()
     events = g.randomEvents(100)
     for i in range(15):
         events[i].setAttribute("foo", "bar")
     attr_foo_is_bar = rulecomponents.event_attribute(
         "foo", lambda **kwargs: "bar", "eq")
     self.assert_(len(attr_foo_is_bar(query_events=events)) == 15)
     for i in range(10, 20):
         events[i].setAttribute("foo", str(i))
     attr_foo_is_ge15 = rulecomponents.event_attribute(
         "foo", lambda **kwargs: "15", "ge")
     attr_foo_is_le10 = rulecomponents.event_attribute(
         "foo", lambda **kwargs: "10", "le")
     self.assert_(len(attr_foo_is_ge15(query_events=events)) == 5)
     self.assert_(attr_foo_is_le10(query_events=events)[0] == events[10])
Exemplo n.º 3
0
	def test_event_attribute_regexp(self):
		g = event.EventGenerator()
		events = g.randomEvents(100)
		events[10].setAttribute("foo", "bar")
		events[11].setAttribute("foo", "baar")
		events[12].setAttribute("foo", "bahr")
		attr_foo_matches_bar = rulecomponents.event_attribute("foo", None, "re", "^baa?r$")
		self.assert_(len(attr_foo_matches_bar(query_events=events))==2)
		self.assert_(attr_foo_matches_bar(query_events=events)[1] == events[11])
Exemplo n.º 4
0
 def test_event_attribute_regexp(self):
     g = event.EventGenerator()
     events = g.randomEvents(100)
     events[10].setAttribute("foo", "bar")
     events[11].setAttribute("foo", "baar")
     events[12].setAttribute("foo", "bahr")
     attr_foo_matches_bar = rulecomponents.event_attribute(
         "foo", None, "re", "^baa?r$")
     self.assert_(len(attr_foo_matches_bar(query_events=events)) == 2)
     self.assert_(
         attr_foo_matches_bar(query_events=events)[1] == events[11])