class TestAdherenceRepeater(ENikshayRepeaterTestBase):
    def setUp(self):
        super(TestAdherenceRepeater, self).setUp()
        self.repeater = NinetyNineDotsAdherenceRepeater(
            domain=self.domain,
            url='case-repeater-url',
        )
        self.repeater.white_listed_case_types = ['adherence']
        self.repeater.save()

    def test_trigger(self):
        self.create_case_structure()
        self._create_99dots_registered_case()
        self._create_99dots_enabled_case()
        self.assertEqual(0, len(self.repeat_records().all()))

        self.create_adherence_cases([datetime(2017, 2, 17)])
        self.assertEqual(0, len(self.repeat_records().all()))

        self.create_adherence_cases([datetime(2017, 2, 18)],
                                    adherence_source='enikshay')
        self.assertEqual(1, len(self.repeat_records().all()))

        self.create_adherence_cases([datetime(2017, 2, 20)],
                                    adherence_source='enikshay')
        self.assertEqual(2, len(self.repeat_records().all()))
Esempio n. 2
0
class TestAdherenceRepeater(ENikshayLocationStructureMixin, ENikshayRepeaterTestBase):

    def setUp(self):
        super(TestAdherenceRepeater, self).setUp()
        self.repeater = NinetyNineDotsAdherenceRepeater(
            domain=self.domain,
            url='case-repeater-url',
        )
        self.repeater.white_listed_case_types = ['adherence']
        self.repeater.save()

    def test_trigger(self):
        self.create_case_structure()
        self._create_99dots_registered_case()
        self._create_99dots_enabled_case()
        self.assign_person_to_location(self.phi.location_id)
        self.assertEqual(0, len(self.repeat_records().all()))

        self.create_adherence_cases([datetime(2017, 2, 17)])
        self.assertEqual(0, len(self.repeat_records().all()))

        self.create_adherence_cases([datetime(2017, 2, 18)], adherence_source='enikshay')
        self.assertEqual(1, len(self.repeat_records().all()))

        case = self.create_adherence_cases([datetime(2017, 2, 20)], adherence_source='enikshay')
        self.assertEqual(2, len(self.repeat_records().all()))

        # Updating the case doesn't make a new repeat record
        self._update_case(case[0].case_id, {'dots_99_error': "hello"})
        self.assertEqual(2, len(self.repeat_records().all()))
 def setUp(self):
     super(TestAdherenceRepeater, self).setUp()
     self.repeater = NinetyNineDotsAdherenceRepeater(
         domain=self.domain,
         url='case-repeater-url',
     )
     self.repeater.white_listed_case_types = ['adherence']
     self.repeater.save()