class TestUpdatePatientRepeater(ENikshayRepeaterTestBase): def setUp(self): super(TestUpdatePatientRepeater, self).setUp() self.repeater = NinetyNineDotsUpdatePatientRepeater( domain=self.domain, url='case-repeater-url', ) self.repeater.white_listed_case_types = ['person', 'episode'] self.repeater.save() def test_trigger(self): self.create_case_structure() self._update_case(self.person_id, { PRIMARY_PHONE_NUMBER: '999999999', }) self.assertEqual(0, len(self.repeat_records().all())) self._create_99dots_registered_case() self.assertEqual(0, len(self.repeat_records().all())) self._update_case(self.person_id, { 'name': 'Elrond', }) self.assertEqual(0, len(self.repeat_records().all())) self._update_case(self.person_id, { PRIMARY_PHONE_NUMBER: '999999999', }) self.assertEqual(1, len(self.repeat_records().all())) self._update_case(self.episode_id, { TREATMENT_SUPPORTER_PHONE: '999999999', }) self.assertEqual(2, len(self.repeat_records().all())) def test_trigger_multiple_cases(self): """Submitting a form with noop case blocks was throwing an exception """ self.create_case_structure() self._create_99dots_registered_case() empty_case = CaseStructure(case_id=self.episode_id, ) person_case = CaseStructure(case_id=self.person_id, attrs={ 'case_type': 'person', 'update': { PRIMARY_PHONE_NUMBER: '9999999999' } }) self.factory.create_or_update_cases([empty_case, person_case]) self.assertEqual(1, len(self.repeat_records().all())) def test_create_person_no_episode(self): """On registration this was failing hard if a phone number was added but no episode was created http://manage.dimagi.com/default.asp?241290#1245284 """ self.create_case(self.person) self.assertEqual(0, len(self.repeat_records().all()))
def setUp(self): super(TestUpdatePatientRepeater, self).setUp() self.repeater = NinetyNineDotsUpdatePatientRepeater( domain=self.domain, url='case-repeater-url', ) self.repeater.white_listed_case_types = ['person', 'episode'] self.repeater.save()
class TestUpdatePatientRepeater(ENikshayRepeaterTestBase): @override_settings(TESTS_SHOULD_USE_SQL_BACKEND=True) def setUp(self): super(TestUpdatePatientRepeater, self).setUp() self.repeater = NinetyNineDotsUpdatePatientRepeater( domain=self.domain, url='case-repeater-url', ) self.repeater.white_listed_case_types = ['person'] self.repeater.save() self.create_case_structure() def _update_person(self, case_properties): return self.create_case( CaseStructure( case_id=self.person_id, attrs={ "case_type": "person", "update": case_properties, } ) ) @override_settings(TESTS_SHOULD_USE_SQL_BACKEND=True) def test_trigger(self): self._update_person({'phone_number': '999999999', }) self.assertEqual(0, len(self.repeat_records().all())) self._create_99dots_registered_case() self.assertEqual(0, len(self.repeat_records().all())) self._update_person({'name': 'Elrond', }) self.assertEqual(0, len(self.repeat_records().all())) self._update_person({'phone_number': '999999999', }) self.assertEqual(1, len(self.repeat_records().all()))