def test_handle_errors_in_redcap_xml_response_fields(self):
        """
        Test the correctness of function
        upload.handle_errors_in_redcap_xml_response()
        """
        self.report_data = {
                'errors':[]
            }

        self.redcap_error = """{
            'error': 'The following fields were not found in the project',
            'fields': ['hcv_im_supplb_vborres', 'hcv_im_nxtrust', 'hcv_im_supplb_lbnote']
        }"""

        upload.handle_errors_in_redcap_xml_response(self.study_id, self.redcap_error, self.report_data)
        self.assertTrue(1 == len(self.report_data['errors']))


        self.redcap_error = """{
            'error': "Missing subjects",
            'subjects': ['1', '2']
        }"""


        upload.handle_errors_in_redcap_xml_response(self.study_id, self.redcap_error, self.report_data)
    def test_handle_errors_in_redcap_xml_response_records(self):
        """
        Test the correctness of function
        upload.handle_errors_in_redcap_xml_response()
        """
        self.report_data = {
                'errors':[]
            }

        self.redcap_error = """{
            "error": "There were data validation errors",
            "records": [
                    {
                        "record": "1 (1_arm_1)",
                        "field_name": "wbc_lborres",
                        "value": "5.4",
                        "message": "This field is located on a form that is locked."
                    },
                    {
                        "record": "1 (1_arm_1)",
                        "field_name": "wbc_x",
                        "value": "5.5",
                        "message": "This field is located on a form that is locked."
                    }

                ]
            }"""

        # Verify that the report_data contains the error
        # after calling `handle_errors_in_redcap_xml_response`
        upload.handle_errors_in_redcap_xml_response(self.study_id, self.redcap_error, self.report_data)
        self.assertTrue(2 == len(self.report_data['errors']))
Beispiel #3
0
    def test_handle_errors_in_redcap_xml_response_fields(self):
        """
        Test the correctness of function
        upload.handle_errors_in_redcap_xml_response()
        """
        self.report_data = {'errors': []}

        self.redcap_error = """{
            'error': 'The following fields were not found in the project',
            'fields': ['hcv_im_supplb_vborres', 'hcv_im_nxtrust', 'hcv_im_supplb_lbnote']
        }"""

        upload.handle_errors_in_redcap_xml_response(self.study_id,
                                                    self.redcap_error,
                                                    self.report_data)
        self.assertTrue(1 == len(self.report_data['errors']))

        self.redcap_error = """{
            'error': "Missing subjects",
            'subjects': ['1', '2']
        }"""

        upload.handle_errors_in_redcap_xml_response(self.study_id,
                                                    self.redcap_error,
                                                    self.report_data)
Beispiel #4
0
    def test_handle_errors_in_redcap_xml_response_records(self):
        """
        Test the correctness of function
        upload.handle_errors_in_redcap_xml_response()
        """
        self.report_data = {'errors': []}

        self.redcap_error = """{
            "error": "There were data validation errors",
            "records": [
                    {
                        "record": "1 (1_arm_1)",
                        "field_name": "wbc_lborres",
                        "value": "5.4",
                        "message": "This field is located on a form that is locked."
                    },
                    {
                        "record": "1 (1_arm_1)",
                        "field_name": "wbc_x",
                        "value": "5.5",
                        "message": "This field is located on a form that is locked."
                    }

                ]
            }"""

        # Verify that the report_data contains the error
        # after calling `handle_errors_in_redcap_xml_response`
        upload.handle_errors_in_redcap_xml_response(self.study_id,
                                                    self.redcap_error,
                                                    self.report_data)
        self.assertTrue(2 == len(self.report_data['errors']))
    def test_handle_errors_in_redcap_xml_response_with_no_errorKey_in_report_data(self):
        
        self.redcap_pass = """{"error": "There were data validation errors","records": [{"record": "1 (1_arm_1)", "field_name": "wbc_lborres",
								"value": "5.4",
								"message": "This field is located on a form that is locked. You must first unlock this form for this record"}]}"""
        self.report_data = {}
        self.assertTrue(upload.handle_errors_in_redcap_xml_response(self.redcap_pass, self.report_data))
    def test_handle_errors_in_redcap_xml_response_valid_case(self):
        """ Test the correctness of function
        upload.handle_errors_in_redcap_xml_response
        """
        self.redcap_error = """{"error": "There were data validation errors","records": [{"record": "1 (1_arm_1)", "field_name": "wbc_lborres",
								"value": "5.4",
								"message": "This field is located on a form that is locked. You must first unlock this form for this record"}]}"""
        self.report_data = {'errors':[]}
        self.assertTrue(upload.handle_errors_in_redcap_xml_response(self.redcap_error, self.report_data))