Skip to content

Commit e940252

Browse files
committed
update invalid headers test
1 parent 19c670c commit e940252

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

test/unit/test_actions.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,10 @@ def test_create_alert_webhook_action_headers(gl_experimental: ExperimentalApi):
186186
assert alert.webhook_action[0].payload_template.headers == headers
187187

188188

189-
def test_create_alert_webhook_action_with_invalid_payload_template_headers(gl_experimental: ExperimentalApi):
190-
name = f"Test {datetime.utcnow()}"
191-
det = gl_experimental.get_or_create_detector(name, "test_query")
192-
condition = gl_experimental.make_condition("CHANGED_TO", {"label": "YES"})
193-
payload_template = gl_experimental.make_payload_template(
194-
'{"template": "This is a fine template"}', headers="bad headers" # type: ignore
195-
)
196-
webhook_action = gl_experimental.make_webhook_action(
197-
url="https://groundlight.ai", include_image=True, payload_template=payload_template
198-
)
199-
200-
bad_request_exception_status_code = 400
201-
202-
with pytest.raises(ApiException) as e:
203-
gl_experimental.create_alert(det, f"test_alert_{name}", condition, webhook_actions=webhook_action)
204-
assert e.value.status == bad_request_exception_status_code
205-
206-
payload_template = gl_experimental.make_payload_template(
207-
"This should not be a valid payload, it's valid jinja but won't produce valid json"
208-
)
209-
webhook_action = gl_experimental.make_webhook_action(
210-
url="https://groundlight.ai", include_image=True, payload_template=payload_template
211-
)
212-
213-
with pytest.raises(ApiException) as e:
214-
gl_experimental.create_alert(det, f"test_alert_{name}", condition, webhook_actions=webhook_action)
215-
assert e.value.status == bad_request_exception_status_code
189+
def test_create_invalid_payload_template_headers(gl_experimental: ExperimentalApi):
190+
with pytest.raises(Exception) as e:
191+
gl_experimental.make_payload_template(
192+
'{"template": "This is a fine template"}', headers="bad headers" # type: ignore
193+
)
194+
assert e.typename == "ValidationError"
195+
assert "Input should be a valid dictionary" in str(e.value)

0 commit comments

Comments
 (0)