def test_handle_success(self):
     date = datetime(2017, 2, 20)
     cases = self.create_case_structure()
     cases['adherence'] = self.create_adherence_cases([date])[0]
     adherence_id = cases['adherence'].case_id
     self.factory.create_or_update_case(
         CaseStructure(
             case_id=adherence_id,
             attrs={
                 'create': False,
                 'update': {
                     'dots_99_error': 'bad things'
                 },
             },
         ))
     payload_generator = AdherencePayloadGenerator(None)
     payload_generator.handle_success(
         MockResponse(200, {"success": "hooray"}), cases['adherence'], None)
     updated_adherence_case = CaseAccessors(
         self.domain).get_case(adherence_id)
     self.assertEqual(
         updated_adherence_case.dynamic_case_properties().get(
             'dots_99_error'), '')
     self.assertEqual(
         updated_adherence_case.dynamic_case_properties().get(
             'dots_99_updated'), 'true')
Beispiel #2
0
 def test_handle_failure(self):
     date = datetime(2017, 2, 20)
     cases = self.create_case_structure()
     cases['adherence'] = self.create_adherence_cases([date])[0]
     adherence_id = cases['adherence'].case_id
     payload_generator = AdherencePayloadGenerator(None)
     error = {
         "error": "Something went terribly wrong",
     }
     payload_generator.handle_failure(MockResponse(400, error), cases['adherence'], None)
     updated_adherence_case = CaseAccessors(self.domain).get_case(adherence_id)
     self.assertEqual(
         updated_adherence_case.dynamic_case_properties().get('dots_99_error'),
         "400: {}".format(error['error'])
     )
 def _get_actual_payload(self, casedb):
     return AdherencePayloadGenerator(None).get_payload(
         None, casedb['adherence'])