Ejemplo n.º 1
0
    def test_get_matrix_not_found(self, mock_get_table_item):
        request_id = str(uuid.uuid4())
        mock_get_table_item.side_effect = MatrixException(status=requests.codes.not_found, title=f"Unable to find")

        response = get_matrix(request_id)

        self.assertEqual(response[1], 404)
        self.assertTrue(request_id in response[0]['message'])
Ejemplo n.º 2
0
    def test_get_matrix_batch_failure(self, mock_get_table_item, mock_batch_job_status, mock_log_error):
        request_id = str(uuid.uuid4())
        mock_get_table_item.return_value = {RequestTableField.ERROR_MESSAGE.value: "",
                                            RequestTableField.FORMAT.value: "test_format"}
        mock_batch_job_status.return_value = "FAILED"

        response = get_matrix(request_id)
        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['status'], MatrixRequestStatus.FAILED.value)
Ejemplo n.º 3
0
    def test_get_matrix_processing__driver_not_initialized(self, mock_is_request_complete, mock_get_table_item,
                                                           mock_initialized):
        request_id = str(uuid.uuid4())
        mock_initialized.return_value = True
        mock_get_table_item.side_effect = MatrixException(status=requests.codes.not_found, title=f"Unable to find")

        response = get_matrix(request_id)

        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['status'], MatrixRequestStatus.IN_PROGRESS.value)
Ejemplo n.º 4
0
    def test_get_matrix_timeout(self, mock_is_request_complete, mock_get_table_item,
                                mock_timeout):
        request_id = str(uuid.uuid4())
        mock_is_request_complete.return_value = False
        mock_get_table_item.return_value = {RequestTableField.ERROR_MESSAGE.value: "",
                                            RequestTableField.FORMAT.value: "test_format"}
        mock_timeout.return_value = True

        response = get_matrix(request_id)
        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['status'], MatrixRequestStatus.FAILED.value)
Ejemplo n.º 5
0
    def test_get_mtx_matrix_complete(self, mock_is_request_complete, mock_get_table_item):
        request_id = str(uuid.uuid4())
        mock_is_request_complete.return_value = True
        mock_get_table_item.return_value = {RequestTableField.ERROR_MESSAGE.value: "",
                                            RequestTableField.FORMAT.value: "mtx"}

        response = get_matrix(request_id)
        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['matrix_location'],
                         f"https://s3.amazonaws.com/{os.environ['MATRIX_RESULTS_BUCKET']}/{request_id}.mtx.zip")

        self.assertEqual(response[0]['status'], MatrixRequestStatus.COMPLETE.value)
Ejemplo n.º 6
0
    def test_get_matrix_failed(self, mock_is_request_complete, mock_get_table_item, mock_initialized):
        request_id = str(uuid.uuid4())
        mock_initialized.return_value = True
        mock_is_request_complete.return_value = False
        mock_get_table_item.return_value = {RequestTableField.ERROR_MESSAGE.value: "test error",
                                            RequestTableField.FORMAT.value: "test_format"}

        response = get_matrix(request_id)

        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['status'], MatrixRequestStatus.FAILED.value)
        self.assertEqual(response[0]['message'], "test error")
Ejemplo n.º 7
0
    def test_get_matrix_processing__post_driver(self, mock_is_request_complete, mock_get_table_item, mock_initialized):
        request_id = str(uuid.uuid4())
        mock_initialized.return_value = True
        mock_is_request_complete.return_value = False
        mock_get_table_item.return_value = {RequestTableField.ERROR_MESSAGE.value: "",
                                            RequestTableField.FORMAT.value: "test_format",
                                            RequestTableField.CREATION_DATE.value: get_datetime_now(as_string=True)}

        response = get_matrix(request_id)

        self.assertEqual(response[1], requests.codes.ok)
        self.assertEqual(response[0]['status'], MatrixRequestStatus.IN_PROGRESS.value)