示例#1
0
def test_notification():
    phases = [
        _execution.WorkflowExecutionPhase.FAILED,
        _execution.WorkflowExecutionPhase.SUCCEEDED,
    ]
    recipients = ["a", "b", "c"]

    obj = _common.Notification(phases,
                               email=_common.EmailNotification(recipients))
    assert obj.phases == phases
    assert obj.email.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.email.recipients_email == recipients

    obj = _common.Notification(
        phases, pager_duty=_common.PagerDutyNotification(recipients))
    assert obj.phases == phases
    assert obj.pager_duty.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.pager_duty.recipients_email == recipients

    obj = _common.Notification(phases,
                               slack=_common.SlackNotification(recipients))
    assert obj.phases == phases
    assert obj.slack.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.slack.recipients_email == recipients
示例#2
0
 def __init__(self, phases: List[int], recipients_email: List[str]):
     """
     :param list[int] phases: A required list of phases for which to fire the event.  Events can only be fired for
         terminal phases.  Phases should be as defined in: flytekit.models.core.execution.WorkflowExecutionPhase
     :param list[str] recipients_email: A required non-empty list of recipients for the notification.
     """
     super(Slack, self).__init__(phases, slack=_common_model.SlackNotification(recipients_email))
示例#3
0
def test_slack_notification():
    slack_notif = notification.Slack(phases=[_workflow_execution_succeeded],
                                     recipients_email=["*****@*****.**"])
    assert slack_notif.to_flyte_idl() == _common_pb2.Notification(
        phases=[_workflow_execution_succeeded],
        email=None,
        pager_duty=None,
        slack=_common_model.SlackNotification(["*****@*****.**"
                                               ]).to_flyte_idl(),
    )
示例#4
0
def test_notification_slack():
    obj = _common.SlackNotification(["a", "b", "c"])
    assert obj.recipients_email == ["a", "b", "c"]
    obj2 = _common.SlackNotification.from_flyte_idl(obj.to_flyte_idl())
    assert obj2 == obj
示例#5
0
def test_notification_slack():
    obj = _common.SlackNotification(['a', 'b', 'c'])
    assert obj.recipients_email == ['a', 'b', 'c']
    obj2 = _common.SlackNotification.from_flyte_idl(obj.to_flyte_idl())
    assert obj2 == obj