|
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 |
|
6 | | -from taskbadger import Action, EmailIntegration, StatusEnum |
| 6 | +from taskbadger import Action, EmailIntegration, StatusEnum, WebhookIntegration |
| 7 | +from taskbadger.exceptions import TaskbadgerException |
7 | 8 | from taskbadger.internal.models import PatchedTaskRequest, PatchedTaskRequestData, TaskRequest, TaskRequestData |
8 | 9 | from taskbadger.internal.types import UNSET, Response |
9 | 10 | from taskbadger.sdk import Badger, Task, init |
@@ -132,17 +133,30 @@ def test_add_actions(settings, patched_update): |
132 | 133 |
|
133 | 134 | patched_update.return_value = Response(HTTPStatus.OK, b"", {}, api_task) |
134 | 135 |
|
135 | | - action = Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")) |
136 | | - task.add_actions([action]) |
| 136 | + task.add_actions( |
| 137 | + [ |
| 138 | + Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")), |
| 139 | + Action("cancelled", integration=WebhookIntegration(id="webhook:123")), |
| 140 | + ] |
| 141 | + ) |
137 | 142 |
|
138 | 143 | # expected request |
139 | 144 | _verify_update( |
140 | 145 | settings, |
141 | 146 | patched_update, |
142 | | - actions=[{"trigger": "*/10%,success,error", "integration": "email", "config": {"to": "me@example.com"}}], |
| 147 | + actions=[ |
| 148 | + {"trigger": "*/10%,success,error", "integration": "email", "config": {"to": "me@example.com"}}, |
| 149 | + {"trigger": "cancelled", "integration": "webhook:123", "config": {}}, |
| 150 | + ], |
143 | 151 | ) |
144 | 152 |
|
145 | 153 |
|
| 154 | +def test_action_validation(): |
| 155 | + WebhookIntegration(id="webhook:123") |
| 156 | + with pytest.raises(TaskbadgerException): |
| 157 | + WebhookIntegration(id="email:123") |
| 158 | + |
| 159 | + |
146 | 160 | def _verify_update(settings, patched_update, **kwargs): |
147 | 161 | actions = kwargs.pop("actions", None) |
148 | 162 | request_params = { |
|
0 commit comments