Skip to content

Commit 73b140e

Browse files
committed
Implement test_queue_filter_sla_breached() function
1 parent 470f38d commit 73b140e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/test_queue_api.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,24 @@ def test_queue_orders_breached_then_due_soon_then_priority_then_age(api_client):
9393

9494
assert ids[0] == breached_claim.id
9595
assert ids[1] == due_soon_claim.id
96-
assert ids.index(normal_old_high.id) < ids.index(normal_old_normal.id)
96+
assert ids.index(normal_old_high.id) < ids.index(normal_old_normal.id)
97+
98+
99+
@pytest.mark.django_db
100+
def test_queue_filter_sla_breached(api_client):
101+
"""sla=breached filter should return only breached items."""
102+
user = User.objects.create_user(username="queue_user2", password="password123")
103+
api_client.force_authenticate(user=user)
104+
105+
policy = PolicyFactory()
106+
c1 = Claim.objects.create(policy=policy, claim_type=Claim.Type.CLAIM, priority=Claim.Priority.NORMAL, summary="B", created_by="x")
107+
SlaClock.objects.create(claim=c1, started_at=c1.created_at, due_at=timezone.now() - timedelta(hours=1))
108+
109+
c2 = Claim.objects.create(policy=policy, claim_type=Claim.Type.CLAIM, priority=Claim.Priority.NORMAL, summary="OK", created_by="x")
110+
SlaClock.objects.create(claim=c2, started_at=c2.created_at, due_at=timezone.now() + timedelta(days=1))
111+
112+
url = reverse("queue-claims")
113+
resp = api_client.get(url, data={"sla": "breached"})
114+
assert resp.status_code == 200
115+
ids = {item["id"] for item in resp.json()}
116+
assert ids == {c1.id}

0 commit comments

Comments
 (0)