"""Alarm related tests."""

from django.urls import reverse

from kalabash.lib.tests import KbashTestCase
from ..factories import populate_database
from ..models import Alarm, Domain


class AlarmsTestCase(KbashTestCase):
    """Alarm open/close test cases."""

    def setUp(self):
        super().setUp()
        populate_database()

    def test_set_forward(self):
        domain = Domain.objects.all().first()
        alarm = Alarm.objects.create(domain=domain, mailbox=None, title="Test alarm 3")
        alarm.save()
        self.assertEqual(alarm.status, 1)
        alarm.close()
        self.assertEqual(alarm.status, 2)
        alarm.reopen()
        self.assertEqual(alarm.status, 1)
