diff --git a/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py b/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py index 812f25857685..30e5d4c0f770 100644 --- a/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py +++ b/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py @@ -211,7 +211,6 @@ def test_Qido_search_small_buffer_flush(self, MockClient): @patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient") def test_param_dict_passing(self, MockClient): - input_dict = {} input_dict = {} input_dict['project_id'] = "test_project" input_dict['region'] = "test_region" @@ -257,7 +256,25 @@ def test_wrong_input_type(self, MockClient): assert_that(results, equal_to([expected_invalid_dict])) @patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient") - def test_missing_parameters(self, MockClient): + def test_missing_project_id(self, MockClient): + input_dict = {} + input_dict['dataset_id'] = "test_dataset" + input_dict['region'] = "test_region" + + expected_invalid_dict = {} + expected_invalid_dict['result'] = [] + expected_invalid_dict['status'] = 'Must have project_id in the dict.' + expected_invalid_dict['input'] = input_dict + expected_invalid_dict['success'] = False + + mc = MockHttpClient() + MockClient.return_value = mc + with TestPipeline() as p: + results = (p | beam.Create([input_dict]) | DicomSearch()) + assert_that(results, equal_to([expected_invalid_dict])) + + @patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient") + def test_missing_dataset_id(self, MockClient): input_dict = {} input_dict['project_id'] = "test_project" input_dict['region'] = "test_region" @@ -274,6 +291,24 @@ def test_missing_parameters(self, MockClient): results = (p | beam.Create([input_dict]) | DicomSearch()) assert_that(results, equal_to([expected_invalid_dict])) + @patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient") + def test_missing_region(self, MockClient): + input_dict = {} + input_dict['project_id'] = "test_project" + input_dict['dataset_id'] = "test_dataset" + + expected_invalid_dict = {} + expected_invalid_dict['result'] = [] + expected_invalid_dict['status'] = 'Must have region in the dict.' + expected_invalid_dict['input'] = input_dict + expected_invalid_dict['success'] = False + + mc = MockHttpClient() + MockClient.return_value = mc + with TestPipeline() as p: + results = (p | beam.Create([input_dict]) | DicomSearch()) + assert_that(results, equal_to([expected_invalid_dict])) + @patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient") def test_client_search_notfound(self, MockClient): input_dict = {}