def test_case_routed_by_second_tier_if_tier_one_conditions_not_met(self): queue_2 = Queue(team=self.team) queue_2.save() flag = FlagFactory(team=self.team) rule = self.create_routing_rule( team_id=self.team.id, queue_id=self.queue.id, tier=5, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[RoutingRulesAdditionalFields.FLAGS], ) rule.flags_to_include.add(flag) self.create_routing_rule( team_id=self.team.id, queue_id=queue_2.id, tier=6, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[], ) case = self.create_open_application_case(organisation=self.organisation) run_routing_rules(case) self.assertNotIn(self.queue, set(case.queues.all())) self.assertIn(queue_2, set(case.queues.all()))
def test_case_routed_to_multiple_queues_with_multiple_team_rules_status_changed(self): queue_2 = Queue(team=self.team) queue_2.save() team_2 = Team(name="team2") team_2.save() self.create_routing_rule( team_id=self.team.id, queue_id=self.queue.id, tier=5, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[], ) self.create_routing_rule( team_id=team_2.id, queue_id=queue_2.id, tier=6, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[], ) case = self.create_open_application_case(organisation=self.organisation) run_routing_rules(case) self.assertIn(self.queue, set(case.queues.all())) self.assertIn(queue_2, set(case.queues.all()))
def test_case_advances_to_next_status_if_rules_not_run(self): queue_2 = Queue(team=self.team) queue_2.save() under_review = CaseStatus.objects.get(status="under_review") self.create_routing_rule( team_id=self.team.id, queue_id=queue_2.id, tier=6, status_id=under_review.id, additional_rules=[], ) case = self.create_open_application_case(organisation=self.organisation) run_routing_rules(case) self.assertIn(queue_2, set(case.queues.all())) self.assertEqual(case.status, under_review)
def test_assignments_persist_if_queue_is_not_removed_from_a_queue(self): CaseAssignment.objects.create(queue=self.queue, case=self.case, user=self.gov_user) self.url = reverse("cases:case", kwargs={"pk": self.case.id}) new_queue = Queue(name="new queue", team=self.team) new_queue.save() data = {"queues": [new_queue.id, self.queue.id]} self.client.put(self.url, data=data, **self.gov_headers) self.assertEqual(len(CaseAssignment.objects.all()), 1)
def test_case_routed_to_one_queue_with_different_rule_tiers_same_team_when_status_changed(self): queue_2 = Queue(team=self.team) queue_2.save() self.create_routing_rule( team_id=self.team.id, queue_id=self.queue.id, tier=5, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[], ) self.create_routing_rule( team_id=self.team.id, queue_id=queue_2.id, tier=6, status_id=CaseStatus.objects.get(status="submitted").id, additional_rules=[], ) case = self.create_open_application_case(organisation=self.organisation) run_routing_rules(case) self.assertIn(self.queue, case.queues.all()) self.assertNotIn(queue_2, case.queues.all())
def create_queue(name: str, team: Team): queue = Queue(name=name, team=team) queue.save() return queue
def create_batch_queues(self, queue_count): print(f"creating {queue_count} queues") queue_details = {"name": "random", "team": self.team} Queue.objects.bulk_create( [Queue(**queue_details) for i in range(0, queue_count)])