oncall-engine/engine/apps/webhooks/tests
Matias Bordese 20ec6f52bc
Add is_legacy column to handle webhook migration (#1813)
Legacy webhooks won't be editable at first. Keep data templates
compatibility.

Possible migration code:
```python
from apps.webhooks.models import Webhook
from apps.alerts.models import CustomButton, EscalationPolicy

custom_buttons = CustomButton.objects.all()
for cb in custom_buttons:
    webhook, _ = Webhook.objects.get_or_create(
        organization=cb.organization,
        team=cb.team,
        name=cb.name,
        is_legacy=True,
        defaults=dict(
            created_at=cb.created_at,
            url=cb.webhook,
            username=cb.user,
            password=cb.password,
            authorization_header=cb.authorization_header,
            trigger_type=Webhook.TRIGGER_ESCALATION_STEP,
            forward_all=cb.forward_whole_payload,
            data=cb.data,
        )
    )
    # migrate related escalation policies
    policies = EscalationPolicy.objects.filter(
        step=EscalationPolicy.STEP_TRIGGER_CUSTOM_BUTTON,
        custom_button_trigger=cb,
    ).update(
        step=EscalationPolicy.STEP_TRIGGER_CUSTOM_WEBHOOK,
        custom_webhook=webhook,
    )

```
2023-04-25 11:22:56 -03:00
..
__init__.py Add webhooks app and initial models (#1101) 2023-03-09 19:39:25 +00:00
factories.py Keep webhook responses data (#1580) 2023-03-21 13:43:37 +00:00
test_alert_group_status_change.py Add unacknowledge trigger for new webhooks (#1768) 2023-04-18 13:03:33 -06:00
test_trigger_webhook.py Add users_to_be_notified to new webhooks payload (#1798) 2023-04-20 16:13:48 +00:00
test_webhook.py Add is_legacy column to handle webhook migration (#1813) 2023-04-25 11:22:56 -03:00