Skip to content

Commit

Permalink
Add test for deleting filter group
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Nov 14, 2023
1 parent f7b53b6 commit 804a40d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/integration/web/alertprofiles_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
AlertSender,
Expression,
Filter,
FilterGroup,
MatchField,
Operator,
)
Expand Down Expand Up @@ -531,6 +532,35 @@ def test_alertprofiles_add_invalid_phone_number_should_fail(client):
assert "Not a valid phone number." in smart_str(response.content)


def test_alertprofiles_confirm_remove_filter_group(db, client, dummy_filter_group):
url = reverse('alertprofiles-filter_groups-remove')
response = client.post(
url,
follow=True,
data={
'confirm': '1',
'element': [dummy_filter_group.id],
},
)
assert response.status_code == 200
assert not FilterGroup.objects.filter(pk=dummy_filter_group.pk).exists()


def test_alertprofiles_remove_filter_group(db, client, dummy_filter_group):
url = reverse('alertprofiles-filter_groups-remove')
response = client.post(
url,
follow=True,
data={
'filter_group': [dummy_filter_group.id],
},
)
assert response.status_code == 200
assert "Confirm deletion" in smart_str(response.content)
assert dummy_filter_group.name in smart_str(response.content)
assert FilterGroup.objects.filter(pk=dummy_filter_group.pk).count() == 1


#
# fixtures and helpers
#
Expand Down Expand Up @@ -558,3 +588,10 @@ def dummy_filter():
filtr = Filter(name="dummy", owner=Account.objects.get(id=Account.ADMIN_ACCOUNT))
filtr.save()
return filtr


@pytest.fixture(scope="function")
def dummy_filter_group(admin_account):
filter_group = FilterGroup(name="dummy_group", owner=admin_account)
filter_group.save()
return filter_group

0 comments on commit 804a40d

Please sign in to comment.