Fix missing timestamp value, add test (#3522)
This commit is contained in:
parent
a46610b096
commit
054401a214
3 changed files with 45 additions and 0 deletions
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix missing timestamp value in old grafana API endpoint ([#3522](https://github.com/grafana/oncall/pull/3522))
|
||||
|
||||
## v1.3.73 (2023-12-06)
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -184,6 +184,46 @@ def test_integration_grafana_endpoint_has_alerts(
|
|||
)
|
||||
|
||||
|
||||
@patch("apps.integrations.views.create_alert")
|
||||
@pytest.mark.django_db
|
||||
def test_integration_old_grafana_endpoint(
|
||||
mock_create_alert, settings, make_organization_and_user, make_alert_receive_channel
|
||||
):
|
||||
settings.DEBUG = False
|
||||
|
||||
integration_type = "grafana"
|
||||
organization, user = make_organization_and_user()
|
||||
alert_receive_channel = make_alert_receive_channel(
|
||||
organization=organization,
|
||||
author=user,
|
||||
integration=integration_type,
|
||||
)
|
||||
|
||||
client = APIClient()
|
||||
url = reverse("integrations:grafana", kwargs={"alert_channel_key": alert_receive_channel.token})
|
||||
|
||||
data = {}
|
||||
now = timezone.now()
|
||||
with patch("django.utils.timezone.now") as mock_now:
|
||||
mock_now.return_value = now
|
||||
response = client.post(url, data, format="json")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
mock_create_alert.apply_async.assert_called_once_with(
|
||||
[],
|
||||
{
|
||||
"title": "Title",
|
||||
"message": None,
|
||||
"image_url": None,
|
||||
"link_to_upstream_details": None,
|
||||
"alert_receive_channel_pk": alert_receive_channel.pk,
|
||||
"integration_unique_data": '{"evalMatches": []}',
|
||||
"raw_request_data": data,
|
||||
"received_at": now.isoformat(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@patch("apps.integrations.views.create_alert")
|
||||
@pytest.mark.parametrize(
|
||||
"integration_type",
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ class GrafanaAPIView(
|
|||
},
|
||||
)
|
||||
else:
|
||||
timestamp = timezone.now().isoformat()
|
||||
create_alert.apply_async(
|
||||
[],
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue