Co-authored-by: Eve832 <eve.meelan@grafana.com>
Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
Co-authored-by: Julia <ferril.darkdiver@gmail.com>
Co-authored-by: maskin25 <kengurek@gmail.com>
Co-authored-by: Matias Bordese <mbordese@gmail.com>
Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
Co-authored-by: Richard Hartmann <richih@richih.org>
Co-authored-by: Robby Milo <robbymilo@fastmail.com>
Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
import pytest
|
|
from django.utils import timezone
|
|
|
|
from apps.alerts.models import AlertReceiveChannel
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_silence_alert_group(
|
|
make_organization_and_user,
|
|
make_alert_receive_channel,
|
|
make_alert_group,
|
|
make_alert,
|
|
mock_start_disable_maintenance_task,
|
|
):
|
|
organization, user = make_organization_and_user()
|
|
alert_receive_channel = make_alert_receive_channel(
|
|
organization, integration=AlertReceiveChannel.INTEGRATION_GRAFANA
|
|
)
|
|
alert_group = make_alert_group(alert_receive_channel)
|
|
alert_group.silence()
|
|
|
|
assert alert_group.silenced is True
|
|
assert alert_group.silenced_at is not None
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_silence_by_user_alert_group(
|
|
make_organization_and_user,
|
|
make_alert_receive_channel,
|
|
make_alert_group,
|
|
make_alert,
|
|
mock_start_disable_maintenance_task,
|
|
):
|
|
organization, user = make_organization_and_user()
|
|
alert_receive_channel = make_alert_receive_channel(
|
|
organization, integration=AlertReceiveChannel.INTEGRATION_GRAFANA
|
|
)
|
|
alert_group = make_alert_group(alert_receive_channel)
|
|
alert_group.silence()
|
|
|
|
assert alert_group.silenced is True
|
|
assert alert_group.silenced_at is not None
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_unsilence_alert_group(
|
|
make_organization_and_user,
|
|
make_alert_receive_channel,
|
|
make_alert_group,
|
|
make_alert,
|
|
mock_start_disable_maintenance_task,
|
|
):
|
|
organization, user = make_organization_and_user()
|
|
alert_receive_channel = make_alert_receive_channel(
|
|
organization, integration=AlertReceiveChannel.INTEGRATION_GRAFANA
|
|
)
|
|
now = timezone.now()
|
|
silenced_until = now + timezone.timedelta(seconds=3600)
|
|
alert_group = make_alert_group(
|
|
alert_receive_channel,
|
|
silenced=True,
|
|
silenced_at=timezone.now(),
|
|
silenced_by_user=user,
|
|
silenced_until=silenced_until,
|
|
)
|
|
alert_group.un_silence()
|
|
|
|
assert alert_group.silenced is False
|
|
assert alert_group.silenced_at is None
|
|
assert alert_group.silenced_until is None
|
|
assert alert_group.silenced_by_user is None
|