Esempio n. 1
0
 def test_handle_bad_nikshay_response(self):
     self._create_nikshay_enabled_case()
     payload_generator = NikshayRegisterPatientPayloadGenerator(None)
     response = {
         "Nikshay_Message": "Success",
         "Results": [
             {
                 "FieldName": "BadResponse",
                 "Fieldvalue": "Borked",
             }
         ]
     }
     payload_generator.handle_success(
         MockResponse(
             201,
             response,
         ),
         self.cases[self.episode_id],
         None,
     )
     updated_episode_case = CaseAccessors(self.domain).get_case(self.episode_id)
     self._assert_case_property_equal(updated_episode_case, 'nikshay_registered', 'false')
     self._assert_case_property_equal(
         updated_episode_case,
         'nikshay_error',
         'No Nikshay ID received: {}'.format(response)
     )
Esempio n. 2
0
 def test_handle_success(self):
     nikshay_id = "NIKSHAY!"
     self._create_nikshay_enabled_case()
     payload_generator = NikshayRegisterPatientPayloadGenerator(None)
     payload_generator.handle_success(
         MockResponse(
             201,
             {
                 "Nikshay_Message": "Success",
                 "Results": [
                     {
                         "FieldName": "NikshayId",
                         "Fieldvalue": nikshay_id,
                     }
                 ]
             }
         ),
         self.cases[self.episode_id],
         None,
     )
     updated_episode_case = CaseAccessors(self.domain).get_case(self.episode_id)
     self._assert_case_property_equal(updated_episode_case, 'nikshay_registered', 'true')
     self._assert_case_property_equal(updated_episode_case, 'nikshay_error', '')
     self._assert_case_property_equal(updated_episode_case, 'nikshay_id', nikshay_id)
     self.assertEqual(updated_episode_case.external_id, nikshay_id)