Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincarrogan committed Oct 24, 2024
1 parent 77df256 commit 04cd2e4
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions api/cases/tests/test_rerun_routing_rules.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import pytest
import uuid

from unittest.mock import patch

from django.urls import reverse
from rest_framework import status

from api.audit_trail.enums import AuditType
from api.audit_trail.models import Audit
from api.cases.enums import CaseTypeSubTypeEnum
from api.staticdata.statuses.enums import CaseStatusEnum
from api.staticdata.statuses.libraries.get_case_status import get_case_status_by_status
from api.staticdata.statuses.models import CaseStatus
from api.workflow.routing_rules.models import RoutingRule

from lite_routing.routing_rules_internal.registries import RoutingRulesRegister

from test_helpers.clients import DataTestClient


Expand All @@ -19,20 +20,28 @@ def setUp(self):
self.queue = self.create_queue("A", self.team)
self.other_queue = self.create_queue("B", self.team)
self.url = reverse("cases:rerun_routing_rules", kwargs={"pk": self.case.id})
self.routing_rule_1 = self.create_routing_rule(
self.team.id,
self.queue.id,
tier=3,
status_id=get_case_status_by_status(CaseStatusEnum.SUBMITTED).id,
additional_rules=[],
)

def test_rules_rerun(self):
@patch(
"lite_routing.routing_rules_internal.routing_engine.routing_rules",
new_callable=RoutingRulesRegister,
)
def test_rules_rerun(self, mock_routing_rules):
self.case.queues.set([self.other_queue.id])

@mock_routing_rules.register(
rule_id=uuid.uuid4(),
case_sub_type=CaseTypeSubTypeEnum.STANDARD,
case_status=CaseStatusEnum.SUBMITTED,
team=self.team.id,
tier=3,
queue=self.queue.id,
)
def rule(case):
return True

response = self.client.put(self.url, {}, **self.gov_headers)

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.case.refresh_from_db()
self.assertEqual(self.case.queues.count(), 2)
self.assertEqual(self.case.queues.first().id, self.queue.id)
self.assertEqual(self.case.queues.count(), 1)
self.assertEqual(self.case.queues.get().id, self.queue.id)

0 comments on commit 04cd2e4

Please sign in to comment.