Beispiel #1
0
 def test_handle_failure(self):
     cases = self.create_case_structure()
     payload_generator = UpdatePatientPayloadGenerator(None)
     error = {
         "error": "Something went terribly wrong",
     }
     payload_generator.handle_failure(MockResponse(400, error), cases[self.person_id], None)
     updated_episode_case = CaseAccessors(self.domain).get_case(self.episode_id)
     self.assertEqual(
         updated_episode_case.dynamic_case_properties().get('dots_99_error'),
         "400: {}".format(error['error'])
     )
Beispiel #2
0
 def test_handle_success(self):
     cases = self.create_case_structure()
     self.factory.create_or_update_case(CaseStructure(
         case_id=self.episode_id,
         attrs={
             'create': False,
             'update': {'dots_99_error': 'bad things'},
         },
     ))
     payload_generator = UpdatePatientPayloadGenerator(None)
     payload_generator.handle_success(MockResponse(200, {"success": "hooray"}), cases[self.person_id], None)
     updated_episode_case = CaseAccessors(self.domain).get_case(self.episode_id)
     self.assertEqual(
         updated_episode_case.dynamic_case_properties().get('dots_99_error'),
         ''
     )
Beispiel #3
0
 def test_get_payload(self):
     cases = self.create_case_structure()
     expected_numbers = u"+91{}, +91{}".format(
         self.primary_phone_number.replace("0", ""),
         self.secondary_phone_number.replace("0", "")
     )
     expected_payload = json.dumps({
         'beneficiary_id': self.person_id,
         'phone_numbers': expected_numbers,
         'merm_id': cases[self.person_id].dynamic_case_properties().get('merm_id')
     })
     actual_payload = UpdatePatientPayloadGenerator(None).get_payload(None, cases[self.person_id])
     self.assertEqual(expected_payload, actual_payload)
 def _get_actual_payload(self, casedb):
     return UpdatePatientPayloadGenerator(None).get_payload(
         None, casedb[self.person_id])