def create_group(self, domain): group = CommCareCaseGroup( name=self.cleaned_data['name'], domain=domain ) group.save() return group
def create_group(self, domain): group = CommCareCaseGroup( name=self.cleaned_data['name'], domain=domain ) group.save() return group
def test_case_group_recipient_with_user_data_filter(self): # The user data filter should have no effect here because all # the recipients are cases. schedule = TimedSchedule.create_simple_daily_schedule( self.domain, TimedEvent(time=time(9, 0)), SMSContent(message={'en': 'Hello'}) ) schedule.user_data_filter = {'role': ['nurse']} schedule.save() with create_case(self.domain, 'person') as case: case_group = CommCareCaseGroup(domain=self.domain, cases=[case.case_id]) case_group.save() self.addCleanup(case_group.delete) instance = CaseTimedScheduleInstance( domain=self.domain, timed_schedule_id=schedule.schedule_id, recipient_type=ScheduleInstance.RECIPIENT_TYPE_CASE_GROUP, recipient_id=case_group.get_id, ) recipients = list(instance.expand_recipients()) self.assertEqual(len(recipients), 1) self.assertEqual(recipients[0].case_id, case.case_id)
def test_case_group_recipient_with_user_data_filter(self): # The user data filter should have no effect here because all # the recipients are cases. schedule = TimedSchedule.create_simple_daily_schedule( self.domain, TimedEvent(time=time(9, 0)), SMSContent(message={'en': 'Hello'}) ) schedule.user_data_filter = {'role': ['nurse']} schedule.save() with create_case(self.domain, 'person') as case: case_group = CommCareCaseGroup(domain=self.domain, cases=[case.case_id]) case_group.save() self.addCleanup(case_group.delete) instance = CaseTimedScheduleInstance( domain=self.domain, timed_schedule_id=schedule.schedule_id, recipient_type=ScheduleInstance.RECIPIENT_TYPE_CASE_GROUP, recipient_id=case_group.get_id, ) recipients = list(instance.expand_recipients()) self.assertEqual(len(recipients), 1) self.assertEqual(recipients[0].case_id, case.case_id)
def test_case_group(self): group = CommCareCaseGroup(name='A', domain=self.domain, cases=['A', 'B']) group.save() self.addCleanup(group.delete) self._test_doc(group.get_id, "CommCareCaseGroup")
def test_get_docs_in_domain_by_class(self): group = Group(domain=self.domain) case_group = CommCareCaseGroup(name='a group', domain=self.domain) group.save() case_group.save() self.addCleanup(group.delete) self.addCleanup(case_group.delete) [group2] = get_docs_in_domain_by_class(self.domain, Group) self.assertEqual(group2.to_json(), group.to_json()) [case_group2] = get_docs_in_domain_by_class(self.domain, CommCareCaseGroup) self.assertEqual(case_group.to_json(), case_group2.to_json())