Skip to content

Commit

Permalink
testsuite: expand testing in t0030-journal.py
Browse files Browse the repository at this point in the history
Problem: There are some gaps in the unit tests for the JournalConsumer
class.

Expand testing to cover the gaps.
  • Loading branch information
grondo committed Oct 25, 2024
1 parent 292bb55 commit b39d861
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions t/python/t0030-journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,42 @@ def test_poll_ENODATA(self):
consumer.stop()
self.assertIsNone(consumer.poll(timeout=5.0))

def test_poll_RuntimeError(self):

with self.assertRaises(RuntimeError):
flux.job.JournalConsumer(self.fh).poll(5.0)

def test_poll_cb_set_before_start(self):

def cb(event):
if event is None:
self.fh.reactor_stop()
elif event.is_empty():
consumer.stop()

consumer = flux.job.JournalConsumer(self.fh, include_sentinel=True)
consumer.set_callback(cb)
consumer.start()
self.fh.reactor_run()

def test_poll_cb_reset(self):
"""test that the consumer callback can be reset"""

def cb(event):
self.fail("incorrect callback called")

def cb2(event):
if event is None:
self.fh.reactor_stop()
elif event.is_empty():
consumer.stop()

consumer = flux.job.JournalConsumer(self.fh, include_sentinel=True)
consumer.set_callback(cb)
consumer.start()
consumer.set_callback(cb2)
self.fh.reactor_run()


if __name__ == "__main__":
if rerun_under_flux(__flux_size()):
Expand Down

0 comments on commit b39d861

Please sign in to comment.