36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
import pytest
|
|
|
|
from incident.models import Incident
|
|
from ncircc.enums.notifications import NotificationCategoryEnum, EventTypeEnum, NotificationStatusEnum
|
|
from ncircc.models.notification import Notification
|
|
from ncircc.services.utils import get_incident_notification_mapper
|
|
|
|
@pytest.mark.unit
|
|
@pytest.mark.django_db
|
|
def test_get_mapper_view_incident_and_notification_id():
|
|
"""Test utils mapper."""
|
|
incident1 = Incident.objects.create(title='test_inc1', importance=10, event_count=10, events='')
|
|
incident2 = Incident.objects.create(title='test_inc2', importance=10, event_count=10, events='')
|
|
incident3 = Incident.objects.create(title='test_inc3', importance=10, event_count=10, events='')
|
|
|
|
notification1 = Notification.objects.create(
|
|
incident=incident1,
|
|
category=NotificationCategoryEnum.INCIDENT.value,
|
|
type=EventTypeEnum.SLOWDOWN_DUE_TO_DDOS.value,
|
|
notification_status=NotificationStatusEnum.ADDITION_REQUIRED.value
|
|
)
|
|
notification2 = Notification.objects.create(
|
|
incident=incident2,
|
|
category=NotificationCategoryEnum.INCIDENT.value,
|
|
type=EventTypeEnum.SLOWDOWN_DUE_TO_DDOS.value,
|
|
notification_status=NotificationStatusEnum.ADDITION_REQUIRED.value
|
|
)
|
|
|
|
data = get_incident_notification_mapper()
|
|
assert isinstance(data, dict)
|
|
assert len(data) == 2
|
|
assert str(incident1.pk) in data
|
|
assert data[str(incident1.pk)] == notification1.id
|
|
assert str(incident2.pk) in data
|
|
assert data[str(incident2.pk)] == notification2.id
|
|
assert str(incident3.pk) not in data
|