def test_20_000_job_event_functions_invalid_args(self): with self.assertRaises(OSError) as cm: for event in job.event_watch(self.fh, 123): print(event) self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: job.event_wait(self.fh, 123, "start") self.assertEqual(cm.exception.errno, errno.ENOENT) with self.assertRaises(OSError) as cm: job.event_wait(None, 123, "start") self.assertEqual(cm.exception.errno, errno.EINVAL)
def test_20_004_job_event_watch(self): jobid = job.submit(self.fh, JobspecV1.from_command(["sleep", "0"])) self.assertTrue(jobid > 0) events = [] for event in job.event_watch(self.fh, jobid): self.assertIsInstance(event, job.EventLogEvent) self.assertTrue(hasattr(event, "timestamp")) self.assertTrue(hasattr(event, "name")) self.assertTrue(hasattr(event, "context")) self.assertIs(type(event.timestamp), float) self.assertIs(type(event.name), str) self.assertIs(type(event.context), dict) events.append(event.name) self.assertEqual(len(events), 10)