Skip to content

Commit

Permalink
skip deprecated props and groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mkangia committed Jun 19, 2024
1 parent 7b27292 commit 2ac1c48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion corehq/apps/data_dictionary/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def setUpClass(cls):
case_type=cls.case_type_obj,
name='TestGroup'
)
cls.case_type_deprecated_group = CasePropertyGroup.objects.create(
case_type=cls.case_type_obj,
name='DeprecatedTestGroup',
deprecated=True,
)
CaseProperty.objects.create(
name='case_prop_1',
case_type=cls.case_type_obj,
Expand Down Expand Up @@ -321,11 +326,27 @@ def test_get_case_property_deprecated_dict(self):
self.assertEqual(dep_dict, expected_response)

def test_get_case_property_group_name_for_properties(self):
# Deprecated case prop
CaseProperty.objects.create(
name='deprecated_case_prop',
case_type=self.case_type_obj,
label='Deprecated Case Prop',
deprecated=True,
group=self.case_type_group,
)
# Deprecated group's case prop
CaseProperty.objects.create(
name='deprecated_group_case_prop_1',
case_type=self.case_type_obj,
label='Deprecated group prop',
group=self.case_type_deprecated_group,
)

case_group_name_for_property = get_case_property_group_name_for_properties(self.domain,
self.case_type_name)
self.assertEqual(
case_group_name_for_property,
{'case_prop_1': 'TestGroup', 'case_prop_2': None}
{'case_prop_1': 'TestGroup'}
)


Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/data_dictionary/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,5 @@ def get_used_props_by_case_type(domain):

def get_case_property_group_name_for_properties(domain, case_type_name):
return dict(CaseProperty.objects.filter(
case_type__name=case_type_name, case_type__domain=domain
case_type__name=case_type_name, case_type__domain=domain, deprecated=False, group__deprecated=False
).values_list('name', 'group__name'))

0 comments on commit 2ac1c48

Please sign in to comment.