Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating composite triggers with the DeploymentTrigger YAML representation #12413

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions tests/events/client/test_deployment_trigger_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,93 @@ def test_compound_deployment_trigger_as_automation():
)


def test_deeply_nested_compound_deployment_trigger_as_automation():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

trigger = pydantic.parse_obj_as(
DeploymentTriggerTypes,
{
"name": "A deployment automation",
"type": "compound",
"require": "all",
"within": "42",
"triggers": [
{
"type": "compound",
"require": "any",
"triggers": [
{"posture": "Reactive", "expect": ["foo.bar"]},
{"posture": "Reactive", "expect": ["buz.baz"]},
],
},
{
"type": "sequence",
"triggers": [
{"posture": "Reactive", "expect": ["flibbdy.jibbidy"]},
{"posture": "Reactive", "expect": ["floobity.bop"]},
],
},
],
},
)
assert isinstance(trigger, DeploymentCompoundTrigger)
trigger.set_deployment_id(uuid4())

automation = trigger.as_automation()

assert automation == Automation(
name="A deployment automation",
description="",
enabled=True,
trigger=CompoundTrigger(
require="all",
triggers=[
CompoundTrigger(
require="any",
triggers=[
EventTrigger(
posture=Posture.Reactive,
threshold=1,
within=datetime.timedelta(0),
expect=["foo.bar"],
),
EventTrigger(
posture=Posture.Reactive,
threshold=1,
within=datetime.timedelta(0),
expect=["buz.baz"],
),
],
),
SequenceTrigger(
triggers=[
EventTrigger(
posture=Posture.Reactive,
threshold=1,
within=datetime.timedelta(0),
expect=["flibbdy.jibbidy"],
),
EventTrigger(
posture=Posture.Reactive,
threshold=1,
within=datetime.timedelta(0),
expect=["floobity.bop"],
),
],
),
],
within=datetime.timedelta(seconds=42),
),
actions=[
RunDeployment(
type="run-deployment",
source="selected",
parameters=None,
deployment_id=trigger._deployment_id,
)
],
owner_resource=f"prefect.deployment.{trigger._deployment_id}",
)


def test_sequence_deployment_trigger_as_automation():
trigger = pydantic.parse_obj_as(
DeploymentTriggerTypes,
Expand Down