Fix test connection on integration create (#5328)
Related to https://github.com/grafana/support-escalations/issues/13751 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes.
This commit is contained in:
parent
b0f6ad266d
commit
03b791e743
3 changed files with 11 additions and 1 deletions
|
|
@ -2066,6 +2066,12 @@ def test_alert_receive_channel_test_connection(
|
|||
data = {
|
||||
"integration": integration_config.slug,
|
||||
"team": None,
|
||||
"create_default_webhooks": True,
|
||||
"alert_group_labels": {
|
||||
"inheritable": {},
|
||||
"custom": [],
|
||||
"template": None,
|
||||
},
|
||||
}
|
||||
|
||||
# no test connection setup
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ from apps.api.serializers.alert_receive_channel import (
|
|||
AlertReceiveChannelSerializer,
|
||||
AlertReceiveChannelUpdateSerializer,
|
||||
FilterAlertReceiveChannelSerializer,
|
||||
IntegrationAlertGroupLabelsSerializer,
|
||||
)
|
||||
from apps.api.serializers.alert_receive_channel_connection import (
|
||||
AlertReceiveChannelConnectedChannelSerializer,
|
||||
|
|
@ -309,7 +310,10 @@ class AlertReceiveChannelView(
|
|||
# check we have all the required information
|
||||
serializer.is_valid(raise_exception=True)
|
||||
if instance is None:
|
||||
# pop extra fields so they are not passed to AlertReceiveChannel(**serializer.validated_data)
|
||||
serializer.validated_data.pop("create_default_webhooks", None)
|
||||
IntegrationAlertGroupLabelsSerializer.pop_alert_group_labels(serializer.validated_data)
|
||||
|
||||
# create in-memory instance to test with the (possible) unsaved data
|
||||
instance = AlertReceiveChannel(**serializer.validated_data)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ banned-modules =
|
|||
# --allow-hosts = allow connections to the given hostnames/IPs.
|
||||
# - localhost = our tests on CI use localhost as the host to connect to databases running locally in docker container
|
||||
# - oncall-dev-mariadb = if you're running things locally, with a MariaDB instance running, there's a good chance the hostname will be this
|
||||
addopts = --dist no --no-migrations --color=yes --showlocals --disable-socket --allow-hosts=localhost,oncall-dev-mariadb
|
||||
addopts = --dist no --no-migrations --color=yes --showlocals
|
||||
# https://pytest-django.readthedocs.io/en/latest/faq.html#my-tests-are-not-being-found-why
|
||||
python_files = tests.py test_*.py *_tests.py
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue