From 124c3c92f454807e49a556a3bab1fcb72d070c61 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Mon, 20 Nov 2023 10:50:21 +0100 Subject: [PATCH] Add tests for equal sysname --- tests/integration/web/alertprofiles_test.py | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/integration/web/alertprofiles_test.py b/tests/integration/web/alertprofiles_test.py index 61d756cb9a..21aadd7b7c 100644 --- a/tests/integration/web/alertprofiles_test.py +++ b/tests/integration/web/alertprofiles_test.py @@ -457,6 +457,32 @@ def test_alertprofiles_add_expression_with_equal_condition_should_succeed( response.content ) + def test_alertprofiles_add_expression_with_equal_sysname_should_succeed( + self, client, dummy_filter + ): + """Tests that an expression with an equals condition for sysname can be + added + """ + group_match_field = MatchField.objects.get(name="Sysname") + url = reverse("alertprofiles-filters-saveexpression") + data = { + "filter": dummy_filter.pk, + "match_field": group_match_field.pk, + "operator": Operator.EQUALS, + "value": "abc", + } + response = client.post(url, data=data, follow=True) + assert response.status_code == 200 + assert Expression.objects.filter( + filter=dummy_filter, + match_field=group_match_field, + operator=Operator.EQUALS, + value=data["value"], + ).exists() + assert f"Added expression to filter {dummy_filter}" in smart_str( + response.content + ) + def test_alertprofiles_add_expression_with_greater_condition_should_succeed( self, client, dummy_filter ):