本文整理汇总了Python中testhelper.assertEventEquals函数的典型用法代码示例。如果您正苦于以下问题:Python assertEventEquals函数的具体用法?Python assertEventEquals怎么用?Python assertEventEquals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertEventEquals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad
def test_bad(self):
self.create({"consume": False, "on_error": "tag"}, [Event(data=x) for x in self.bad_packets])
events = self.wait(events=len(self.bad_packets))
bad_events = [Event(data=x, message="invalid syslog", tags=["error"]) for x in self.bad_packets]
for ev in bad_events:
assertEventEquals(self, ev, events.pop(0))
示例2: test_good
def test_good(self):
self.create({},
[Event(data=x) for x in self.good_packets])
events = self.wait(events=len(self.good_events))
for ev in self.good_events:
assertEventEquals(self, ev, events.pop(0))
示例3: test_simple
def test_simple(self):
function = mock.Mock()
ev = Event(data="abc123")
self.create({"function": function}, [ev])
q = self.wait()
assertEventEquals(self, Event(data="abc123"), q[0])
function.assert_called_with(ev)
示例4: test_bad
def test_bad(self):
self.create({'consume': False, 'on_error': 'tag'},
[Event(data=x) for x in self.bad_packets])
events = self.wait(events=len(self.bad_packets))
bad_events = [Event(data=x, message='invalid syslog', tags=['error']) for x in self.bad_packets]
for ev in bad_events:
assertEventEquals(self, ev, events.pop(0))
示例5: test_event
def test_event(self):
conf = {'port': random.randint(1024, 65535)}
self.create(conf)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.sendto('abc', ('', conf['port']))
# yield for processing to happen
q = self.waitForQueue()
assertEventEquals(self, Event(data='abc'), q[0])
示例6: test_allow_hosts
def test_allow_hosts(self):
conf = {'port': random.randint(1024, 65535),
'allow_hosts': ['127.0.0.1']}
self.create(conf)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.sendto('abc', ('', conf['port']))
q = self.waitForQueue()
assertEventEquals(self, Event(data='abc'), q[0])
示例7: test_multiple
def test_multiple(self):
with TempDirectory():
conf = {'path': 'test*.log'}
self.create(conf)
with file('test1.log', 'w') as fin:
print >> fin, 'abc'
with file('test2.log', 'w') as fin:
print >> fin, 'abc'
q = self.waitForQueue(events=2)
assertEventEquals(self, Event(data='abc'), q[0])
assertEventEquals(self, Event(data='abc'), q[1])
示例8: test_truncated
def test_truncated(self):
with TempDirectory():
conf = {'path': 'test*.log'}
self.create(conf)
with file('test1.log', 'w') as fin:
print >> fin, 'abc'
print >> fin, 'def'
gevent.sleep(0.01)
with file('test1.log', 'w') as fin:
print >> fin, 'ghi'
q = self.waitForQueue(events=3)
assertEventEquals(self, Event(data='abc'), q[0])
示例9: test_success
def test_success(self):
with TempDirectory():
conf = {'path': 'test*.log'}
self.create(conf)
# create log after a short time
gevent.sleep(0.01)
with file('test1.log', 'w') as fin:
print >> fin, 'abc'
gevent.sleep(0.01)
print >> fin, 'def'
q = self.waitForQueue(events=2)
assertEventEquals(self, Event(data='abc'), q[0])
assertEventEquals(self, Event(data='def'), q[1])
示例10: test_max_size
def test_max_size(self):
with TempDirectory():
self.create({'filename': 'output.log',
'max_size': 16})
map(self.input.put, self.events)
self.waitForEmpty()
self.assertFileContents(self.events[0].to_json()+'\n', 'output.log.1')
self.assertFileContents(self.events[1].to_json()+'\n', 'output.log')
# assert the 'fileroll' event is generated
self.assert_(self.output.qsize())
events = [self.output.get() for i in xrange(self.output.qsize())]
assertEventEquals(self, Event(tags=['fileroll'], filename='output.log.1', last=self.events[0], trigger=self.events[1]), events[1])
示例11: test_resume
def test_resume(self):
with TempDirectory():
with file('test1.log', 'w') as fin:
print >> fin, 'abc'
conf = {'path': 'test*.log'}
self.create(conf)
q = self.waitForQueue(events=1)
assertEventEquals(self, Event(data='abc'), q[0])
with file('test1.log', 'a') as fin:
print >> fin, 'def'
self.create(conf)
q = self.waitForQueue(events=1)
assertEventEquals(self, Event(data='def'), q[0])
示例12: test_rolling
def test_rolling(self):
with TempDirectory():
with file('test1.log', 'w') as fin:
print >> fin, 'abc'
conf = {'path': 'test*.log'}
self.create(conf)
gevent.sleep(0.01)
os.rename('test1.log', 'test1.log.1')
with file('test1.log', 'w') as fin:
print >> fin, 'def'
q = self.waitForQueue(events=2)
assertEventEquals(self, Event(data='abc'), q[0])
assertEventEquals(self, Event(data='def'), q[1])
示例13: test_nested
def test_nested(self):
self.create({"period": 0.1, "metrics": {"rails.{controller}.{action}.{0}": "timings.*"}}, self.events)
# 8 events expected - the above 6, and then 2 stat events
q = self.wait(events=8)
q = [i for i in q if i.stats]
q.sort(key=lambda k: k.metric)
expected = Event(
metric="rails.home.index.timings.view",
stats={
"count": 3,
"max": 2.3,
"mean": 1.5,
"median": 1.2,
"min": 1.0,
"rate": between(1, 100),
"stddev": about(2.34, 2),
"upper95": 2.19,
"upper99": 2.278,
},
tags=["stat"],
)
assertEventEquals(self, expected, q[0])
expected = Event(
metric="rails.home.login.timings.view",
stats={
"count": 1,
"max": 2.0,
"mean": 2.0,
"median": 2.0,
"min": 2.0,
"rate": between(1, 100),
"stddev": 0.0,
"upper95": 2.0,
"upper99": 2.0,
},
tags=["stat"],
)
assertEventEquals(self, expected, q[1])
# wait for further two 'zero' stats
q = self.wait(events=2)
示例14: test_nested
def test_nested(self):
self.create({'period': 0.1, 'metrics': {'rails.{controller}.{action}.{0}': 'timings.*'}},
self.events)
# 8 events expected - the above 6, and then 2 stat events
q = self.wait(events=8)
q = [i for i in q if i.stats]
q.sort(key=lambda k: k.metric)
expected = Event(metric='rails.home.index.timings.view',
stats={
'count': 3,
'max': 2.3,
'mean': 1.5,
'median': 1.2,
'min': 1.0,
'rate': between(1, 100),
'stddev': about(2.34, 2),
'upper95': 2.19,
'upper99': 2.278},
tags=['stat'],
)
assertEventEquals(self, expected, q[0])
expected = Event(metric='rails.home.login.timings.view',
stats={
'count': 1,
'max': 2.0,
'mean': 2.0,
'median': 2.0,
'min': 2.0,
'rate': between(1, 100),
'stddev': 0.0,
'upper95': 2.0,
'upper99': 2.0},
tags=['stat'],
)
assertEventEquals(self, expected, q[1])
# wait for further two 'zero' stats
q = self.wait(events=2)
示例15: test_timestamped
def test_timestamped(self):
events = [
Event(message='1', timestamp=datetime(2013, 1, 1, 23, 59, 58)),
Event(message='2', timestamp=datetime(2013, 1, 1, 23, 59, 59)),
Event(message='3', timestamp=datetime(2013, 1, 2, 0, 0, 0)),
Event(message='4', timestamp=datetime(2013, 1, 2, 0, 0, 1))]
with TempDirectory():
self.create({'filename': 'output-{timestamp:%Y%m%d}.log',
'compress': 'gz'})
map(self.input.put, events)
self.waitForEmpty()
self.assertFileContents(events[0].to_json()+'\n'+events[1].to_json()+'\n', 'output-20130101.log.1.gz')
self.assertFileContents(events[2].to_json()+'\n'+events[3].to_json()+'\n', 'output-20130102.log')
# assert the 'fileroll' event is generated
self.assertEquals(len(events)+1, self.output.qsize())
outputs = [self.output.get() for i in xrange(self.output.qsize())]
assertEventEquals(self, Event(tags=['fileroll'], filename='output-20130101.log.1.gz', last=events[1], trigger=events[2]), outputs[2])