diff --git a/engine/apps/api/tests/test_alert_receive_channel.py b/engine/apps/api/tests/test_alert_receive_channel.py index 6378de0c..460c335e 100644 --- a/engine/apps/api/tests/test_alert_receive_channel.py +++ b/engine/apps/api/tests/test_alert_receive_channel.py @@ -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 diff --git a/engine/apps/api/views/alert_receive_channel.py b/engine/apps/api/views/alert_receive_channel.py index e70be142..19c40a57 100644 --- a/engine/apps/api/views/alert_receive_channel.py +++ b/engine/apps/api/views/alert_receive_channel.py @@ -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: diff --git a/engine/tox.ini b/engine/tox.ini index be2959bb..3e98f312 100644 --- a/engine/tox.ini +++ b/engine/tox.ini @@ -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