-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33432 from dimagi/mjr/duplicate_case_rule_filter_…
…tests
- Loading branch information
Showing
4 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions
35
corehq/apps/reports/tests/standard/cases/filters/test_duplicate_case_rule_filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.test import TestCase | ||
from django.test.client import RequestFactory | ||
|
||
from corehq.apps.data_interfaces.models import AutomaticUpdateRule | ||
from corehq.apps.reports.standard.cases.filters import DuplicateCaseRuleFilter | ||
|
||
|
||
class TestDuplicateCaseRuleFilter(TestCase): | ||
def test_get_value_returns_rule(self): | ||
dedupe_rule = self._create_rule(domain='domain') | ||
request = self._create_request_for_rule(dedupe_rule) | ||
|
||
value = DuplicateCaseRuleFilter.get_value(request, domain='domain') | ||
self.assertEqual(value, str(dedupe_rule.id)) | ||
|
||
def test_get_value_returns_none_on_data_from_other_domain(self): | ||
unauthorized_rule = self._create_rule(domain='unauthorized-domain') | ||
request = self._create_request_for_rule(unauthorized_rule) | ||
|
||
self.assertIsNone(DuplicateCaseRuleFilter.get_value(request, domain='domain')) | ||
|
||
def setUp(self): | ||
self.factory = RequestFactory() | ||
|
||
def _create_rule(self, domain): | ||
return AutomaticUpdateRule.objects.create( | ||
domain=domain, | ||
name='test-rule', | ||
case_type='test-case-type', | ||
workflow=AutomaticUpdateRule.WORKFLOW_DEDUPLICATE, | ||
active=True | ||
) | ||
|
||
def _create_request_for_rule(self, rule): | ||
return self.factory.get('dedupe_report_url', data={'duplicate_case_rule': rule.id}) |