def test_update_klio_log(mocker, monkeypatch, caplog, mock_config): mock_ts = mocker.Mock() monkeypatch.setattr(klio_pb2.KlioJobAuditLogItem, "timestamp", mock_ts) kmsg = klio_pb2.KlioMessage() kmsg.version = klio_pb2.Version.V2 assert not kmsg.metadata.job_audit_log # sanity check with test_pipeline.TestPipeline() as p: in_pcol = p | beam.Create([kmsg.SerializeToString()]) act_pcol = in_pcol | helpers.KlioUpdateAuditLog() _ = act_pcol | beam.Map(assert_audit) exp_log = ( "KlioMessage full audit log - Entity ID: - Path: not-a-real-project::" "a-job (current job)") for rec in caplog.records: if exp_log in rec.message: assert True break else: assert False, "Expected debug audit log not found"
def _update_audit_log(self, in_pcol, label_pfx=None): label = "Updating KlioMessage Audit Log" if label_pfx: label = "[{}] {}".format(label_pfx, label) return in_pcol | label >> helpers.KlioUpdateAuditLog()