Example #1
0
    def test_process_message_with_error_operation(self):
        person = self.tutor.person
        _set_all_application_in_pending_state(self.attribution.applications)
        self.attribution.save()
        ## Check if all are in pending
        self.assertEqual(len(self.attribution.applications), 2)
        self.assertEqual(self.attribution.applications[0]['pending'], tutor_application_epc.UPDATE_OPERATION)
        self.assertEqual(self.attribution.applications[1]['pending'], tutor_application_epc.UPDATE_OPERATION)

        body = {
            'operation': tutor_application_epc.UPDATE_OPERATION,
            'global_id': person.global_id,
            'learning_container_year': {
                'acronym': 'LBIR1200',
                'year': 2017
            },
            tutor_application_epc.ERROR_EPC_FIELD: 'An error occured in EPC'
        }
        body_encoded = bytearray(json.dumps(body), "utf-8")
        tutor_application_epc.process_message(body_encoded)
        # Check if the application is removed
        self.attribution.refresh_from_db()
        applications_not_pending = [application for application in self.attribution.applications if
                                    not "pending" in application]
        self.assertEqual(len(applications_not_pending), 0) # No changed
Example #2
0
 def test_process_message_delete_operation(self):
     person = self.tutor.person
     self.assertEqual(len(self.attribution.applications), 2)
     body = {
         'operation': tutor_application_epc.DELETE_OPERATION,
         'global_id': person.global_id,
         'learning_container_year': {
             'acronym': 'LBIR1200',
             'year': 2017
         }
     }
     body_encoded = bytearray(json.dumps(body), "utf-8")
     tutor_application_epc.process_message(body_encoded)
     # Check if the application is removed
     self.attribution.refresh_from_db()
     self.assertEqual(len(self.attribution.applications), 1)
     attribution_left = self.attribution.applications[0]
     self.assertEqual(attribution_left['acronym'], self.lagro2630.acronym)