From ff071d711db7b78c1f49f8c6d939896dde23d3f8 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Tue, 5 Sep 2023 11:59:33 +0200 Subject: [PATCH] Use db fixture in tests --- tests/integration/models/alert_test.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/integration/models/alert_test.py b/tests/integration/models/alert_test.py index a824245ddb..c3cf957104 100644 --- a/tests/integration/models/alert_test.py +++ b/tests/integration/models/alert_test.py @@ -16,21 +16,21 @@ import pytest -def test_delete_alert_subscription(alert, alertsub, account_alert_queue): +def test_delete_alert_subscription(db, alert, alertsub, account_alert_queue): alertsub.delete() assert not AccountAlertQueue.objects.filter(pk=account_alert_queue.pk).exists() assert not AlertQueue.objects.filter(pk=alert.pk).exists() def test_sending_alert_to_alert_address_with_empty_address_will_raise_error( - alert_address, alert, alertsub + db, alert_address, alert, alertsub ): with pytest.raises(InvalidAlertAddressError): alert_address.send(alert, alertsub) def test_sending_alert_to_alert_address_with_invalid_address_will_raise_error( - alert_address, alert, alertsub + db, alert_address, alert, alertsub ): alert_address.address = "abc" alert_address.save() @@ -39,19 +39,19 @@ def test_sending_alert_to_alert_address_with_invalid_address_will_raise_error( def test_sending_alert_to_alert_address_with_invalid_address_will_delete_alert_and_fail( - alert, account_alert_queue + db, alert, account_alert_queue ): assert not account_alert_queue.send() assert not AlertQueue.objects.filter(pk=alert.pk).exists() @pytest.fixture -def account(): +def account(db): return Account.objects.get(pk=Account.ADMIN_ACCOUNT) @pytest.fixture -def alert_address(account): +def alert_address(db, account): addr = AlertAddress( account=account, type=AlertSender.objects.get(name=AlertSender.SMS), @@ -63,7 +63,7 @@ def alert_address(account): @pytest.fixture -def alert_profile(account): +def alert_profile(db, account): profile = AlertProfile(account=account) profile.save() yield profile @@ -72,7 +72,7 @@ def alert_profile(account): @pytest.fixture -def time_period(alert_profile): +def time_period(db, alert_profile): time_period = TimePeriod(profile=alert_profile) time_period.save() yield time_period @@ -81,7 +81,7 @@ def time_period(alert_profile): @pytest.fixture -def alertsub(alert_address, time_period): +def alertsub(db, alert_address, time_period): alertsub = AlertSubscription( alert_address=alert_address, time_period=time_period, @@ -94,7 +94,7 @@ def alertsub(alert_address, time_period): @pytest.fixture -def alert(): +def alert(db): alert = AlertQueue( source=Subsystem.objects.first(), time=datetime.now(), value=1, severity=3 ) @@ -105,7 +105,7 @@ def alert(): @pytest.fixture -def account_alert_queue(alert, alertsub): +def account_alert_queue(db, alert, alertsub): account_queue = AccountAlertQueue(alert=alert, subscription=alertsub) account_queue.save() yield account_queue