Skip to content

Commit

Permalink
tests BoboNullEventElapse 2
Browse files Browse the repository at this point in the history
  • Loading branch information
r3w0p committed Apr 25, 2022
1 parent 4cb576e commit 528afc6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_engine/test_receiver/test_null_event/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2022 The BoboCEP Authors
# The following code can be redistributed and/or modified
# under the terms of the GNU General Public License v3.0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2022 The BoboCEP Authors
# The following code can be redistributed and/or modified
# under the terms of the GNU General Public License v3.0.

from time import sleep

from bobocep.engine.receiver.null_event.bobo_null_event_elapse import \
BoboNullEventElapse
from bobocep.events.bobo_event_primitive import BoboEventPrimitive


def test_not_from_now():
gen = BoboNullEventElapse(1000, lambda: 123, from_now=False)
event_id = "id"
event = gen.maybe_generate(event_id)

assert type(event) == BoboEventPrimitive
assert event.event_id == event_id
assert event.data == 123


def test_from_now_not_gen():
gen = BoboNullEventElapse(int(3.6e+6), lambda: 123)
event = gen.maybe_generate("id")

assert event is None


def test_from_now_gen():
gen = BoboNullEventElapse(1, lambda: 123)
sleep(1)
event = gen.maybe_generate("id")

assert type(event) == BoboEventPrimitive

0 comments on commit 528afc6

Please sign in to comment.